doUpdateSQL method

  1. @override
FutureOr doUpdateSQL(
  1. String entityName,
  2. String table,
  3. SQL sql,
  4. Object id,
  5. Transaction transaction,
  6. PostgreSQLConnectionWrapper connection, {
  7. bool allowAutoInsert = false,
})
override

Implementation

@override
FutureOr doUpdateSQL(String entityName, String table, SQL sql, Object id,
    Transaction transaction, PostgreSQLConnectionWrapper connection,
    {bool allowAutoInsert = false}) {
  if (sql.isFullyDummy) return id;

  return connection
      .mappedResultsQuery(sql.sql,
          substitutionValues: sql.parametersByPlaceholder)
      .resolveMapped((results) {
    if (results.isEmpty) {
      var entry = sql.parametersByPlaceholder;
      if (!allowAutoInsert) {
        throw StateError(
            "Can't update not stored entity into table `$table`: $entry");
      }

      var fields = sql.namedParameters!;
      return _updateAutoInsert(
          transaction, entityName, table, fields, connection);
    }

    return _resolveResultID(results, table, sql);
  });
}