DoUpdate<T extends Table, D>.withExcluded constructor
- Insertable<
D> update(- T old,
- T excluded
- {List<
Column< ? target,Object> > - Expression<
bool> targetCondition(- T table
- Expression<
bool> where(- T old,
- T excluded
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.
It can refer to the values from the old row in the first parameter and
to columns in the row that couldn't be inserted with the excluded
parameter.
A DO UPDATE
clause must refer to a set of columns potentially causing a
conflict, and only a conflict on those columns causes this clause to be
applied. The most common conflict would be an existing row with the same
primary key, which is the default for target. Other unique indices can
be targeted too. If such a unique index has a condition, it can be set
with targetCondition
(which forms the rarely used WHERE
in the
conflict target).
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.withExcluded(
Insertable<D> Function(T old, T excluded) update, {
this.target,
Expression<bool> Function(T table)? targetCondition,
Expression<bool> Function(T old, T excluded)? where,
}) : _creator = update,
_usesExcludedTable = true,
_targetCondition = targetCondition,
_where = where == null
? null
: ((old, excluded) => Where(where(old, excluded)));