mirror of
https://github.com/smogon/pokemon-showdown-loginserver.git
synced 2026-04-26 01:31:42 -05:00
Database: Fix 'update' queries for PG-derived DBs
PG/Cockroach do not support 'limit' clauses in update queries, so this has to be edited out where applicable.
This commit is contained in:
parent
1cec1eaa36
commit
37b5fbcd1d
|
|
@ -291,7 +291,11 @@ export class DatabaseTable<Row, DB extends Database> {
|
|||
}
|
||||
update(primaryKey: BasicSQLValue, data: PartialOrSQL<Row>) {
|
||||
if (!this.primaryKeyName) throw new Error(`Cannot update() without a single-column primary key`);
|
||||
return this.updateAll(data)`WHERE "${this.primaryKeyName}" = ${primaryKey} LIMIT 1`;
|
||||
// cockroach/pg do not support limit in update queries so we have to case this
|
||||
return this.updateAll(data)`
|
||||
WHERE "${this.primaryKeyName}" = ${primaryKey}
|
||||
${this.db.type === 'mysql' ? SQL` LIMIT 1` : ''}
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user