insertOnConflictUpdate method
Attempts to insert entity
into the database. If the insert would
violate a primary key or uniqueness constraint, updates the columns that
are present on entity
.
Note that this is subtly different from InsertMode.replace! When using
InsertMode.replace, the old row will be deleted and replaced with the
new row. With insertOnConflictUpdate, columns from the old row that are
not present on entity
are unchanged, and no row will be deleted.
Be aware that insertOnConflictUpdate uses an upsert clause, which is not available on older sqlite implementations. Note: By default, only the primary key is used for detect uniqueness violations. If you have further uniqueness constraints, please use the general insert method with a DoUpdate including those columns in its DoUpdate.target.
Implementation
Future<int> insertOnConflictUpdate(Insertable<D> entity) {
return insert(entity, onConflict: DoUpdate((_) => entity));
}