Database: Remove LIMIT clauses from primary key mutating methods

PG doesn't support LIMIT in these, and they don't need it anyway since primary keys should be unique.
This commit is contained in:
Mia 2025-08-04 22:16:35 -05:00
parent d32ad3dc98
commit a341d3c566

View File

@ -321,11 +321,11 @@ export class DatabaseTable<Row, DB extends Database> {
}
delete(primaryKey: BasicSQLValue) {
if (!this.primaryKeyName) throw new Error(`Cannot delete() without a single-column primary key`);
return this.deleteAll()`WHERE "${this.primaryKeyName}" = ${primaryKey} LIMIT 1`;
return this.deleteAll()`WHERE "${this.primaryKeyName}" = ${primaryKey}`;
}
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`;
return this.updateAll(data)`WHERE "${this.primaryKeyName}" = ${primaryKey}`;
}
}
@ -335,7 +335,6 @@ export class MySQLDatabase extends Database<mysql.Pool, mysql.OkPacket> {
const prefix = config.prefix || "";
if (config.prefix) {
config = { ...config };
delete config.prefix;
}
super(mysql.createPool(config), prefix);
}