-
Notifications
You must be signed in to change notification settings - Fork 249
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 on Android throws SQLiteException no such column on "<TableName>2" #2632
Comments
Hi @RobsonT thanks for sharing this issue with us. Can you please confirm if you did the following:
|
Hello @fjnoyp, |
Hi @RobsonT at a glance of the exception message, it's foreign key constraint error. This would happen when you created some "child" records that belong to a "parent", but the "parent" record doesn't exist in the DB. Take this schema: type Insumo @model @auth(rules: [{allow: public}]) {
id: ID!
nome: String
grupoinsumoID: ID! @index(name: "byGrupoInsumo")
PropriedadeInsumos: [PropriedadeInsumo] @hasMany(indexName: "byInsumo", fields: ["id"])
grupoInsumo: GrupoInsumo @belongsTo(fields: ["grupoinsumoID"])
} When you create a record of |
Hi @HuiSF , |
Hi @HuiSF, I tried deleting all the data from the tables and starting from scratch to make sure I didn't have any inconsistent data. But when I tried to register the data I came across the following error: Do you know what could be causing this problem? |
Hi @RobsonT apologies for the delayed response, and thank you for providing more info. Re: the screenshot, were you trying to add model records inside Amplify Studio? Could you describe in details of the steps you were doing? |
Hi @HuiSF I was following the previous tip about the problem being the foreign key pointing to non-existent data. For this I deleted all data from all tables. Then I started inserting data, doing it directly through amplify studio. My idea was to start inserting table by table and test in the flutter app if any errors were generated. However, when registering in the Company table, which was the first table in which I went to register, the image error appeared, not showing the registration form. This error started after I ran amplify upgrade, so I don't know if it was a bug in the latest version. I saw that there was an issue with the same problem at aws-amplify/amplify-studio#825 . However, this error is different from my initial error, but I need it resolved so that I can solve my first problem. In addition to the error in amplify studio, when I ran amplify codegen models, with the latest version of amplify I noticed that the model columns that served as foreign keys were no longer being generated in the schema.js file, causing some errors in my web system as well. |
OK thanks for the clarification @RobsonT It looks like an Amplify Studio issue, and there was a fix implemented already. You probably need to wait for the fix to be released on Amplify Studio side. |
ok. Is there an estimate of when it will be released @HuiSF ? |
I don't have visibility into the release schedule of Amplify Studio at this moment, @RobsonT , I can try to find out. But this shouldn't be a blocker for your issue. You can go ahead to continue testing in your App with amplify-flutter library using e.g. an
The newly created records should be seen in your DynamoDB table. Please give it a try and let me know if anything. |
@HuiSF, since yesterday, amplify studio has the problem solved and I managed to insert the data I needed. I inserted it in some tables, and for each table I inserted a single row. However, when inserting in the |
Hi @RobsonT Thanks for the follow up. It sounds like the DataStore couldn't sync data from cloud. I just noticed that you have 42 models defined. AppSync allows 100 subscriptions per App instance, each model creates 3 subscriptions You may need to consider to optimize the model schema and reduce the model number to ensure the sync work correctly. Here's a thread discussing about this limit. |
Hi @HuiSF my subscription limit per connection has already been increased to 200 in December 2022. Shouldn't that be enough to solve the problem? |
Good to know @RobsonT that shouldn't be the case then.
Looking at the schema of If so, could you also try to query these 4 models respectively see if you can get corresponding records from the local DB. |
@HuiSF, I did not fill in
|
That exception reminds me about this amplify-android issue aws-amplify/amplify-android#2035 But that should be a separate issue from You can do this by
In addition, please provide complete App running log, starting from App launch till the exception occurs. So far I saw all the exception logs from Android, you also checked this issue is happening on iOS, please confirm if you are actually experiencing the same issue on iOS. |
Here is the logs on android @HuiSF . It's been a while since I ran it on ios, but there it was with the same error. I will test again and let you know if the error continues. |
Thanks for providing the attachments @RobsonT I took a look at the logs, the original I've spotted the issue in the SQL command that amplify-android generates, exactly the same cause described in the linked amplify-android issue. I will reach out to the amplify-android maintainers and try to get the fix prioritized. |
Hello @HuiSF, Do you know when the fix will be available? |
Hi @RobsonT we are expecting the fix for 0.6.x version to be released by this week. |
Hello @HuiSF, sorry for the delay in responding. We have tested the new version and confirm that the problem has been resolved. Thanks. |
Thanks for confirming and the feedback! |
Description
I have all the backend done in aws amplify and it works normally in the web system (react) and it worked in the flutter app. But since I added
@belongsto
relationships to some fields with 1:n relationships the system stopped working in flutter (still working in react). Some tables are returning data normally, but others generate the error:message=Error in querying the model., cause=DataStoreException{message=Invalid SQL statement...}
Categories
Steps to Reproduce
No response
Screenshots
Platforms
Flutter Version
3.3.10
Amplify Flutter Version
0.6.10
Deployment Method
Amplify CLI
The text was updated successfully, but these errors were encountered: