mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-03-21 17:25:10 -05:00
Database: Revert syntax for multiline queries
As explicitly documented in `CONTRIBUTING.md`, we are against multiline template strings. While I see the advantages in readability for the multiline approach, I'd rather not send extraneous whitespace to the database.
This commit is contained in:
parent
4a8341586a
commit
f770b255f3
|
|
@ -300,11 +300,9 @@ export class DatabaseTable<Row, DB extends Database> {
|
|||
}
|
||||
upsert(partialRow: PartialOrSQL<Row>, partialUpdate = partialRow, where?: SQLStatement) {
|
||||
if (this.db.type === 'pg') {
|
||||
return this.queryExec()`
|
||||
INSERT INTO "${this.name}" (${partialRow as any})
|
||||
ON CONFLICT (${this.primaryKeyName}) DO UPDATE
|
||||
SET ${partialUpdate as any} ${where}
|
||||
`;
|
||||
return this.queryExec(
|
||||
)`INSERT INTO "${this.name}" (${partialRow as any}) ON CONFLICT (${this.primaryKeyName
|
||||
}) DO UPDATE SET ${partialUpdate as any} ${where}`;
|
||||
}
|
||||
return this.queryExec(
|
||||
)`INSERT INTO "${this.name}" (${partialRow as any}) ON DUPLICATE KEY UPDATE ${partialUpdate as any} ${where}`;
|
||||
|
|
@ -312,10 +310,9 @@ export class DatabaseTable<Row, DB extends Database> {
|
|||
replace(partialRow: PartialOrSQL<Row>, where?: SQLStatement) {
|
||||
if (this.db.type === 'pg') {
|
||||
if (!this.primaryKeyName) throw new Error(`Cannot replace() without a single-column primary key`);
|
||||
return this.queryExec()`
|
||||
INSERT INTO "${this.name}" (${partialRow as any})
|
||||
ON CONFLICT ("${this.primaryKeyName}") DO UPDATE SET ${partialRow as any} ${where}
|
||||
`;
|
||||
return this.queryExec(
|
||||
)`INSERT INTO "${this.name}" (${partialRow as any}) ON CONFLICT ("${this.primaryKeyName
|
||||
}") DO UPDATE SET ${partialRow as any} ${where}`;
|
||||
}
|
||||
return this.queryExec()`REPLACE INTO "${this.name}" (${partialRow as SQLValue}) ${where}`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user