doUpdate method

InsertWithValuesBuilder<S, R, void> doUpdate(
  1. List<Updateable> assignments, {
  2. Filter? where,
})

Close the clause with DO UPDATE SET ..., updating the existing row with assignments, optionally only where where holds.

Reference the row that failed to insert with excluded.

Implementation

InsertWithValuesBuilder<S, R, void> doUpdate(
  List<Updateable<dynamic>> assignments, {
  Filter? where,
}) {
  if (_target.isEmpty) {
    throw StateError(
      'DO UPDATE requires a conflict target, give onConflict() the unique '
      'columns the insert can conflict on.',
    );
  }
  return _close(
    SQL([
      const RawSQL('DO UPDATE SET'),
      UpdateSetClause(UpdateableResult<void>(assignments)),
      if (where != null) ...[const RawSQL('WHERE'), where],
    ]),
  );
}