In a typical Blog & Post schema, when I delete a post instance (belonging to a Blog) from let's say a iOS device, I get an error while (android DataStore is) querying for that item in the local datastore before deleting from it.
android.database.sqlite.SQLiteException: ambiguous column name: id (code 1 SQLITE_ERROR): , while compiling: SELECT `Post`.`id` AS `Post_id`, `Post`.`created` AS `Post_created`, `Post`.`rating` AS `Post_rating`, `Post`.`title` AS `Post_title`, `Post`.`blogID` AS `Post_blogID`, `Blog`.`id` AS `Blog_id`, `Blog`.`name` AS `Blog_name` FROM `Post` LEFT JOIN `Blog` ON `Post`.`blogID`=`Blog`.`id` WHERE id = ? LIMIT ? OFFSET ?;
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:986)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:593)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:590)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:61)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:46)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1443)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1382)
at com.amplifyframework.datastore.storage.sqlite.SQLiteStorageAdapter.getQueryAllCursor(SQLiteStorageAdapter.java:825)
at com.amplifyframework.datastore.storage.sqlite.SQLiteStorageAdapter.lambda$query$5$SQLiteStorageAdapter(SQLiteStorageAdapter.java:406)
at com.amplifyframework.datastore.storage.sqlite.-$$Lambda$SQLiteStorageAdapter$YrR7B1Rj3JmC_omOKlzMTn0U5hM.run(Unknown Source:10)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
W/System.err: android.database.sqlite.SQLiteException: ambiguous column name: id (code 1 SQLITE_ERROR): , while compiling: SELECT `Post`.`id` AS `Post_id`, `Post`.`created` AS `Post_created`, `Post`.`rating` AS `Post_rating`, `Post`.`title` AS `Post_title`, `Post`.`blogID` AS `Post_blogID`, `Blog`.`id` AS `Blog_id`, `Blog`.`name` AS `Blog_name` FROM `Post` LEFT JOIN `Blog` ON `Post`.`blogID`=`Blog`.`id` WHERE id = ? LIMIT ? OFFSET ?;
at com.amplifyframework.datastore.storage.sqlite.SQLiteStorageAdapter.lambda$query$5$SQLiteStorageAdapter(SQLiteStorageAdapter.java:451)
at com.amplifyframework.datastore.storage.sqlite.-$$Lambda$SQLiteStorageAdapter$YrR7B1Rj3JmC_omOKlzMTn0U5hM.run(Unknown Source:10)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
The three variables were
0 = "<a UUId>"
1 = "1"
2 = "0"
Non connected models (such as blog's) get deleted from android DataStore fine.
Hi @Amplifiyer, let me make sure I understand your steps.
Blog and a Post, where a blog "has many" posts, and each post "belongs to" a blog.Blog and a Post remotely, and they sync to two clients (an iOS client and an Android client), both.android.database.sqlite.SQLiteException: ambiguous column name: id (code 1 SQLITE_ERROR): , while compiling: SELECT `Post`.`id` AS `Post_id`, `Post`.`created` AS `Post_created`, `Post`.`rating` AS `Post_rating`, `Post`.`title` AS `Post_title`, `Post`.`blogID` AS `Post_blogID`, `Blog`.`id` AS `Blog_id`, `Blog`.`name` AS `Blog_name` FROM `Post` LEFT JOIN `Blog` ON `Post`.`blogID`=`Blog`.`id` WHERE id = ? LIMIT ? OFFSET ?;
@jamesonwilliams You are absolutely right. For step #2 I'm creating Blog and Post instances from either android or iOS device and made sure that they are synced to android devices before I tried to delete them.