Improve docs on `DoUpdate.target`.

This commit is contained in:
Simon Binder 2022-01-25 13:39:24 +01:00
parent 130517473b
commit 528b5762a6
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
3 changed files with 13 additions and 1 deletions

View File

@ -163,7 +163,7 @@ abstract class DatabaseConnectionUser {
/// This method is deprecated. For an even easier access, the methods that
/// were made available here are now available on the [table] or view instance
/// directly.
@Deprecated('Experiment ended - use the methods on the [table] direclty')
@Deprecated('Experiment ended - use the methods on the [table] directly')
TableOrViewOperations<T, D> from<T extends HasResultSet, D>(
ResultSetImplementation<T, D> table) {
return TableOrViewOperations._(this, table);

View File

@ -48,6 +48,10 @@ extension TableStatements<Tbl extends Table, Row> on TableInfo<Tbl, Row> {
///
/// Please note that this method is only available on recent sqlite3 versions.
/// See also [InsertStatement.insertOnConflictUpdate].
/// By default, only the primary key is used for detect uniqueness violations.
/// If you have further uniqueness constraints, please use the general
/// [insertOne] method with a [DoUpdate] including those columns in its
/// [DoUpdate.target].
Future<int> insertOnConflictUpdate(Insertable<Row> row) {
return insert().insertOnConflictUpdate(row);
}

View File

@ -51,6 +51,10 @@ class InsertStatement<T extends Table, D> {
/// Be aware that upsert clauses and [onConflict] are not available on older
/// sqlite versions.
///
/// By default, the [onConflict] clause will only consider the table's primary
/// key. If you have additional columns with uniqueness constraints, you have
/// to manually add them to the clause's [DoUpdate.target].
///
/// Returns the `rowid` of the inserted row. For tables with an auto-increment
/// column, the `rowid` is the generated value of that column. The returned
/// value can be inaccurate when [onConflict] is set and the insert behaved
@ -104,6 +108,10 @@ class InsertStatement<T extends Table, D> {
///
/// 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].
Future<int> insertOnConflictUpdate(Insertable<D> entity) {
return insert(entity, onConflict: DoUpdate((_) => entity));
}