fixTableSequenceSQL static method
The SQL that moves the ID sequence of table after its greatest ID
(after an auto-insert with an explicit ID, see _fixeTableSequence).
The greatest ID is of the column idFieldName (quoted, as the table),
the column of the sequence: not a literal id column, that a table
with another ID column doesn't have.
Implementation
@visibleForTesting
static String fixTableSequenceSQL(String table, String idFieldName) =>
"SELECT setval(pg_get_serial_sequence("
"${DBSQLAdapter.sqlStringLiteral(table)}, "
"${DBSQLAdapter.sqlStringLiteral(idFieldName)}), "
"coalesce(max(\"$idFieldName\"),0) + 1, false) FROM \"$table\"";