updated upsert (untested)

This commit is contained in:
Ulysia 2025-01-06 21:20:00 +01:00
parent dfa75b046a
commit eecee44129

View file

@ -148,19 +148,19 @@ class SqlSystem {
if(auctionid.length === lbin.length) {
await conn.query(`
INSERT INTO auctions (auctionid, LBin)
VALUES (?,?)
ON DUPLICATE KEY UPDATE
LBin = VALUES(LBin);
`,[await this.UnifiedArray(auctionid,lbin)]);
VALUES ($1,$2)
ON CONFLICT (auctionid)
DO UPDATE SET LBin = $2;
`, [auctionid, lbin]);
}
else if(Array.isArray(auctionid) || Array.isArray(lbin))
throw Error(`Upsert SQL Function error - cannot unify collection ${Array.isArray(auctionid) ? auctionid : lbin} to singlet ${!Array.isArray(auctionid) ? auctionid : lbin}`);
else {
await conn.query(`
INSERT INTO auctions (auctionid, LBin)
VALUES (?,?)
ON DUPLICATE KEY UPDATE
LBin = VALUES(LBin);
VALUES ($1,$2)
ON CONFLICT (auctionid)
DO UPDATE SET LBin = $2;
`, [auctionid, lbin]);
}
await conn.query('COMMIT');