-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Usage of transactions in :memory:
database was broken with #105
#229
Comments
async transaction(mode: TransactionMode = "write"): Promise<Transaction> {
const db = this.#getDb();
executeStmt(db, transactionModeToBegin(mode), this.#intMode);
if (this.#path !== ':memory:') {
this.#db = null; // A new connection will be lazily created on next use
}
return new Sqlite3Transaction(db, this.#intMode);
}
// Lazily creates the database connection and returns it
#getDb(): Database.Database {
if (this.#db === null && this.$path !== ':memory:') {
this.#db = new Database(this.#path, this.#options);
}
return this.#db;
} |
Related? tursodatabase/libsql#1411 |
This is fixed in 0.9.0 |
thewilkybarkid
added a commit
to PREreview/prereview.org
that referenced
this issue
Oct 9, 2024
The tests began to fail when re-enabling transactions as they're incompatible with in-memory SQLite databases. It should be possible to use `file::memory:?cache=shared` rather than `:memory:`, but this also doesn't entirely. To avoid spending more time on this problem, this commit uses temporary file-based databases in the tests. Refs #1973, 3acf814, tursodatabase/libsql-client-ts#229, https://www.sqlite.org/inmemorydb.html
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#105 regressed in memory databases when transactions are used. Once a transaction is created, the entire in memory database will be effectively discarded for subsequent db operations that the client makes.
From the regressing PR.
In particular, this line of code from within
transaction
,null
's outthis.#db
.Subsequent calls to
#getDb
will create a new database here. Because it's purely in memory, this essentially creates a new empty database.I wonder if the fix would be as simple as skipping the dropping/recreating of the
Database
ifpath === ':memory'
.The text was updated successfully, but these errors were encountered: