DoUpdate<T extends Table, D> constructor

DoUpdate<T extends Table, D>(
  1. Insertable<D> update(
    1. T old
    ), {
  2. List<Column>? target,
  3. Expression<bool?> where(
    1. T old
    )?,
})

Creates a DO UPDATE clause.

The update function will be used to construct an Insertable used to update an old row that prevented an insert. If you need to refer to both the old row and the row that would have been inserted, use DoUpdate.withExcluded.

The optional where clause can be used to disable the update based on the old value. If a where clause is set and it evaluates to false, a conflict will keep the old row without applying the update.

For an example, see InsertStatement.insert.

Implementation

DoUpdate(Insertable<D> Function(T old) update,
    {this.target, Expression<bool?> Function(T old)? where})
    : _creator = ((old, _) => update(old)),
      _where = where == null ? null : ((old, _) => Where(where(old))),
      _usesExcludedTable = false;