Jaguar-dart / jaguar_orm

Source-generated ORM with relations (one-to-one, one-to-many, many-to-many), preloading, cascading, polymorphic relations, etc
https://jaguar-dart.github.io
BSD 3-Clause "New" or "Revised" License
217 stars 54 forks source link

InsertMany with primaryKey set to auto #184

Open Skuallpa opened 4 years ago

Skuallpa commented 4 years ago

Hello,

My model as the primary key set auto

class MyModel {
 @PrimaryKey(auto: true)
 int id;

 // .. other fields
}

When I'm trying to insert many of those object at once using insertMany, I got the error that the table has one more column that the values supplied:

await _myModelBean.insertMany(myModels);

table myTable has 3 columns but 2 values were supplied

This works if I insert using a loop like below, but this is probably much heavier in term of performance:

for (final myModel in myModels) {
    await _myModelBean.insert(myModel);
}

How to use "insertMany" with the primary key set to auto generation?

Thanks in advance