better-sqlite3 icon indicating copy to clipboard operation
better-sqlite3 copied to clipboard

lastInsertRowid wrong for upserts

Open Mwni opened this issue 2 years ago • 1 comments

It appears the library returns an incorrect lastInsertRowid for queries such as

INSERT INTO "Account" ( "address"  , "balance" ) 
VALUES ( @address , @balance ) 
ON CONFLICT DO UPDATE SET "address" = excluded."address", "balance" = excluded."balance"

the incorrect id is always the last inserted id of a row of an unrelated table in the database.

Mwni avatar May 03 '22 04:05 Mwni

Can you please provide a minimal self-contained repro? Preferably a single JS file that only depends on better-sqlite3 and that sets everything up using a :memory: db.

Prinzhorn avatar May 03 '22 06:05 Prinzhorn

@Mwni , still waiting on that reproducible example...

JoshuaWise avatar Oct 12 '22 15:10 JoshuaWise

Closing due to inactivity

JoshuaWise avatar Nov 21 '22 23:11 JoshuaWise