-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DataStore Error having two relationships with the same model #494
Comments
Hello, I was browsing around and have come across this filing here. I think we may have a similar use case and thus have encountered the same problem. You can find my filing here: DataStore SQLiteException: Ambiguous Column Name It appears to currently be a limitation with query generation. What I've done is to change the model of my data - which I am fortunate enough that I would still be able then in terms of my development progress. Though, it has been tagged for a more long term fix. At least, another use case can be noted from this. |
Thanks @infernal008 it seems like we encountered the same issue. I ended up doing the same as you, changed the relationships for the model identifiers and ended up querying them in different steps. |
This is a bug report I just filed that includes a couple of bugs I found and the workarounds to each |
@Lorenzohidalgo it looks like the underlying issue in Amplify-Android has been resolved, and would have been available since Amplify-flutter 0.3.2. It is possible there is some work required to consume this fix in Amplify-Flutter though. Have you attempted this with Amplify-flutter 0.3.2 or later? |
@Jordan-Nelson I stopped using DataStore for my application. I'm not able to test it with the newer versions. |
Okay. No worries. We can attempt to reproduce this with the latest version of amplify-flutter. I am going to label this as |
As the fix has been released with previous amplify-flutter updates to integrate the latest version of amplify-android, I'm going to optimistically close this issue. Please feel free the follow up or reopen if anything. Thanks. |
Describe the bug
The autogenerated code for a data schema does not support having multiple relationships with the same data model.
Error: android.database.sqlite.SQLiteException throws an exception for duplicated column names.
Thrown Exception
DataStoreException (DataStoreException(message: Error in saving the model: Transfers[id=4fd38eb3-ed48-4452-870e-ae3d5f748116], recoverySuggestion: See attached exception for details., underlyingException: android.database.sqlite.SQLiteException: ambiguous column name: Users.id (code 1 SQLITE_ERROR): , while compiling: SELECT `Transfers`.`id` AS `Transfers_id`, `Transfers`.`isPublic` AS `Transfers_isPublic`, `Transfers`.`likesUserIDs` AS `Transfers_likesUserIDs`, `Transfers`.`message` AS `Transfers_message`, `Transfers`.`transferDate` AS `Transfers_transferDate`, `Transfers`.`transfersFromUserId` AS `Transfers_transfersFromUserId`, `Transfers`.`transfersToUserId` AS `Transfers_transfersToUserId`, `Users`.`id` AS `Users_id`, `Users`.`avatarKey` AS `Users_avatarKey`, `Users`.`cognito_uid` AS `Users_cognito_uid`, `Users`.`description` AS `Users_description`, `Users`.`email` AS `Users_email`, `Users`.`joinDate` AS `Users_joinDate`, `Users`.`lastLogIn` AS `Users_lastLogIn`, `Users`.`name` AS `Users_name`, `Users`.`phoneNumber` AS `Users_phoneNumber`, `Users`.`id` AS `Users_id`, `Users`.`avatarKey` AS `Users_avatarKey`, `Users`.`cognito_uid` AS `Users_cognito_uid`, `Users`.`description` AS `Users_description`, `Users`.`email` AS `Users_email`, `Users`.`joinDate` AS `Users_joinDate`, `Users`.`lastLogIn` AS `Users_lastLogIn`, `Users`.`name` AS `Users_name`, `Users`.`phoneNumber` AS `Users_phoneNumber` FROM `Transfers` INNER JOIN `Users` ON `Transfers`.`transfersFromUserId`=`Users`.`id` INNER JOIN `Users` ON `Transfers`.`transfersToUserId`=`Users`.`id` WHERE (`Transfers`.`id` = ? AND 1 = 1);))
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The autogenerated code should differ the relationships using its name for the sql querys.
Screenshots
Platform
Amplify Flutter current supports iOS and Android. This issue is reproducible in (check all that apply):
[X] Android
[] iOS
Output of
flutter doctor -v
Smartphone (please complete the following information):
Additional context
Error Logs
E/amplify:flutter:datastore(20026): Caused by: android.database.sqlite.SQLiteException: ambiguous column name: Users.id (code 1 SQLITE_ERROR): , while compiling: SELECT `Transfers`.`id` AS `Transfers_id`, `Transfers`.`isPublic` AS `Transfers_isPublic`, `Transfers`.`likesUserIDs` AS `Transfers_likesUserIDs`, `Transfers`.`message` AS `Transfers_message`, `Transfers`.`transferDate` AS `Transfers_transferDate`, `Transfers`.`transfersFromUserId` AS `Transfers_transfersFromUserId`, `Transfers`.`transfersToUserId` AS `Transfers_transfersToUserId`, `Users`.`id` AS `Users_id`, `Users`.`avatarKey` AS `Users_avatarKey`, `Users`.`cognito_uid` AS `Users_cognito_uid`, `Users`.`description` AS `Users_description`, `Users`.`email` AS `Users_email`, `Users`.`joinDate` AS `Users_joinDate`, `Users`.`lastLogIn` AS `Users_lastLogIn`, `Users`.`name` AS `Users_name`, `Users`.`phoneNumber` AS `Users_phoneNumber`, `Users`.`id` AS `Users_id`, `Users`.`avatarKey` AS `Users_avatarKey`, `Users`.`cognito_uid` AS `Users_cognito_uid`, `Users`.`description` AS `Users_description`, `Users`.`email` AS `Users_email`, `Users`.`joinDate` AS `Users_joinDate`, `Users`.`lastLogIn` AS `Users_lastLogIn`, `Users`.`name` AS `Users_name`, `Users`.`phoneNumber` AS `Users_phoneNumber` FROM `Transfers` INNER JOIN `Users` ON `Transfers`.`transfersFromUserId`=`Users`.`id` INNER JOIN `Users` ON `Transfers`.`transfersToUserId`=`Users`.`id` WHERE (`Transfers`.`id` = ? AND 1 = 1); E/amplify:flutter:datastore(20026): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) E/amplify:flutter:datastore(20026): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1045) E/amplify:flutter:datastore(20026): at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:652) E/amplify:flutter:datastore(20026): at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:590) E/amplify:flutter:datastore(20026): at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:61) E/amplify:flutter:datastore(20026): at android.database.sqlite.SQLiteQuery.(SQLiteQuery.java:37) E/amplify:flutter:datastore(20026): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:46) E/amplify:flutter:datastore(20026): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1545) E/amplify:flutter:datastore(20026): at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1484) E/amplify:flutter:datastore(20026): at com.amplifyframework.datastore.storage.sqlite.SQLiteStorageAdapter.getQueryAllCursor(SQLiteStorageAdapter.java:912) E/amplify:flutter:datastore(20026): at com.amplifyframework.datastore.storage.sqlite.SQLiteStorageAdapter.modelExists(SQLiteStorageAdapter.java:843) E/amplify:flutter:datastore(20026): at com.amplifyframework.datastore.storage.sqlite.SQLiteStorageAdapter.lambda$save$3$SQLiteStorageAdapter(SQLiteStorageAdapter.java:274) E/amplify:flutter:datastore(20026): ... 6 moreThe text was updated successfully, but these errors were encountered: