compileUpdate method

Compiled compileUpdate(
  1. QueryBuilder<Object?> q,
  2. Map<String, Object?> values
)

Implementation

Compiled compileUpdate(QueryBuilder<Object?> q, Map<String, Object?> values) {
  final bindings = <Object?>[];
  final sets = values.entries
      .map((e) {
        final column = wrapValue(assertIdentifier(e.key));
        final value = e.value;
        if (value is RawSql) return '$column = ${_raw(value, bindings)}';
        bindings.add(encode(value));
        return '$column = ?';
      })
      .join(', ');
  final where = compileWheres(q.wheres, bindings);
  return (
    'update ${wrapTable(q.table)} set $sets'
        '${where.isEmpty ? '' : ' where $where'}',
    bindings,
  );
}