updated upsert (untested)
This commit is contained in:
parent
dfa75b046a
commit
eecee44129
1 changed files with 7 additions and 7 deletions
|
@ -148,19 +148,19 @@ class SqlSystem {
|
||||||
if(auctionid.length === lbin.length) {
|
if(auctionid.length === lbin.length) {
|
||||||
await conn.query(`
|
await conn.query(`
|
||||||
INSERT INTO auctions (auctionid, LBin)
|
INSERT INTO auctions (auctionid, LBin)
|
||||||
VALUES (?,?)
|
VALUES ($1,$2)
|
||||||
ON DUPLICATE KEY UPDATE
|
ON CONFLICT (auctionid)
|
||||||
LBin = VALUES(LBin);
|
DO UPDATE SET LBin = $2;
|
||||||
`,[await this.UnifiedArray(auctionid,lbin)]);
|
`, [auctionid, lbin]);
|
||||||
}
|
}
|
||||||
else if(Array.isArray(auctionid) || Array.isArray(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}`);
|
throw Error(`Upsert SQL Function error - cannot unify collection ${Array.isArray(auctionid) ? auctionid : lbin} to singlet ${!Array.isArray(auctionid) ? auctionid : lbin}`);
|
||||||
else {
|
else {
|
||||||
await conn.query(`
|
await conn.query(`
|
||||||
INSERT INTO auctions (auctionid, LBin)
|
INSERT INTO auctions (auctionid, LBin)
|
||||||
VALUES (?,?)
|
VALUES ($1,$2)
|
||||||
ON DUPLICATE KEY UPDATE
|
ON CONFLICT (auctionid)
|
||||||
LBin = VALUES(LBin);
|
DO UPDATE SET LBin = $2;
|
||||||
`, [auctionid, lbin]);
|
`, [auctionid, lbin]);
|
||||||
}
|
}
|
||||||
await conn.query('COMMIT');
|
await conn.query('COMMIT');
|
||||||
|
|
Loading…
Reference in a new issue