-
Notifications
You must be signed in to change notification settings - Fork 52
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
insertMany doesn't work if the model doesn't provide id field #97
Comments
Can you please provide Thanks. |
What DB are you using? Postgres, MYSQL or sqflite? |
Do you get any error? |
I assume you are using sqflite. |
yes, sqflite. I got the db error that id column is empty when |
I also have this issue with using insertMany with sqflite. I can provide you more info if needed. To avoid this, I'm inserting manually each entry of the list, but it is very slow... It takes about 7 seconds for about 1300 entries, each with 17 fields, on a Samsung S8 |
@jaumard Can you look into this? @andrei-cimpan Why are you not providing id? Is it because the id is auto incrementing? The code for models and beans would be of huge help. Thanks! |
Yes guys please share the model and the generated file associated with it. It will be easier to see the problem :) thanks !! |
Also what's the error you receive ? |
Hi @jaumard! I'm not providing id beacuse the id is auto incrementing, just like you said. The pubspec.yaml part that involves Jaguar is:
Actually I have two errors:
I've attached the two source files, model + generated. Calling method: Thanks! |
i also have this problem, my model id is auto incremented insert many doesnt work, i insert it using loop, |
A small reproducable repo will be very useful. |
same problem . and i use upsertMany instead for temporary . |
Sorry to get to this late. I added a repo to reproduce this. Running the below app and the test function: Future testInsertMany() async {
String dbPath = await getDatabasesPath();
SqfliteAdapter adapter = SqfliteAdapter(path.join(dbPath, "test"));
await adapter.connect();
UserBean userBean = UserBean(adapter);
PostBean postBean = PostBean(adapter);
List<User> users = [
User(name: "1"),
User(name: "2"),
];
userBean.insertMany(users, cascade: true);
} You would see this error right away: Text error messages:
@tejainece @jaumard Hope this helps. |
@tejainece @jaumard When inserting into the table the following error is shown in the Android log table my_table has 15 columns but 14 values were supplied The This causes the error because the generated insert statement in To fix this the |
Using |
Looking at the generated code:
when setting
cascade
as true, it uses theinsert
path which handles the case without id field. When settingcascade
as false, there's a bug in the aboveelse
block that doesn't handle id as null. This caught us by surprise.The text was updated successfully, but these errors were encountered: