tursodatabase / libsql-client-ts

TypeScript/JavaScript client API for libSQL
https://docs.turso.tech/sdk/ts/quickstart
MIT License
289 stars 37 forks source link

sqlite3: use one connection per transaction #105

Closed psarna closed 1 year ago

psarna commented 1 year ago

This commit attempts to implement the following mechanism:

  1. A single connection is created lazily whenever user executes a statement
  2. When a transaction starts, the Transaction object takes ownership of the current transaction.
  3. Subsequent queries will create a new connection.

That way we can safely run multiple transactions from a single client, without risking a "cannot begin transaction within transaction" error that comes from trying to send BEGIN twice on a single db connection.

psarna commented 1 year ago

@penberg NOTE: this is entirely untested yet, because I have no idea how to run tests for this typescript driver, and this is pretty much the first snippet of typescript code I ever produced. I'll keep researching how to validate this

psarna commented 1 year ago

@penberg any clue why CI with Vercel Edge fails? It doesn't look related to the patch