compileForUpdate method

String compileForUpdate(
  1. Query<dynamic, QueryWhere> query
)

Implementation

String compileForUpdate(Query query) {
  var data = toMap();
  if (data.isEmpty) return null;
  var b = StringBuffer('SET');
  int i = 0;

  for (var entry in data.entries) {
    if (i++ > 0) b.write(',');
    b.write(' ');
    b.write(entry.key);
    b.write('=');

    var name = query.reserveName(entry.key);
    var s = applyCast(entry.key, '@$name');
    query.substitutionValues[name] = entry.value;
    b.write(s);
  }
  return b.toString();
}