vlcn-io / js

Components to build apps in JavaScript atop cr-sqlite
MIT License
51 stars 6 forks source link

use uuid as savepoint name #32

Closed AlexErrant closed 9 months ago

AlexErrant commented 9 months ago

The primary cause of this PR is this line from the docs:

The ROLLBACK command without a TO clause rolls backs all transactions

I think the current behavior of busting out of all transactions seems too much. Note that even though the rollback causes "The SAVEPOINT with the matching name [to] remains on the transaction stack", the subsequent RELEASE on L109 will (more or less) close out the transaction and commit nothing. I think. I've tested nothing 😅

I also made the names UUIDs because even though "The transaction names need not be unique", it just feels safer. Feel free to assuage me of my paranoia.

tantaman commented 9 months ago

I'll merge this today. I also need to update core extension code in cr-sqlite base on these learnings 😬

AlexErrant commented 9 months ago

Gonna assume here that

Error: unrecognized token: "496204c772af430b9c19a3a0df61094d"

in the failed run is due to starting with a numeric

sqlite> savepoint 2good4u;
Parse error: unrecognized token: "2good4u"
  savepoint 2good4u;
            ^--- error here
sqlite> savepoint x2good4u;
sqlite>