doUpdateSQL method
FutureOr
doUpdateSQL(
- String entityName,
- String table,
- SQL sql,
- Object id,
- Transaction transaction,
- DBSQLMemoryAdapterContext connection, {
- bool allowAutoInsert = false,
override
Implementation
@override
FutureOr doUpdateSQL(String entityName, String table, SQL sql, Object id,
Transaction transaction, DBSQLMemoryAdapterContext connection,
{bool allowAutoInsert = false}) {
if (sql.isDummy) return id;
var map = _getTableMap(table, true)!;
var prevEntry = map[id];
var entry = _normalizeEntityJSON(sql.parametersByPlaceholder,
entityName: entityName, table: table);
if (prevEntry == null) {
if (!allowAutoInsert) {
throw StateError(
"Can't update not stored entity into table `$table`: $entry");
}
var tablesScheme = tablesSchemes[table];
var idField = tablesScheme?.idFieldName ?? 'id';
entry[idField] ??= id;
map[id] = entry;
_disposeNextIDCounter(table);
} else {
var updated = deepCopyMap(prevEntry)!;
updated.addAll(entry);
map[id] = updated;
}
_onTablesModification();
return id;
}