From eecee44129751e6ca7a20f68b634eb4b4222c4c4 Mon Sep 17 00:00:00 2001 From: ulysia Date: Mon, 6 Jan 2025 21:20:00 +0100 Subject: [PATCH] updated upsert (untested) --- src/sqlFunctions.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sqlFunctions.ts b/src/sqlFunctions.ts index d9ce4b1..879a09b 100644 --- a/src/sqlFunctions.ts +++ b/src/sqlFunctions.ts @@ -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');