tursodatabase/libsql-client-ts

When using an in-memory database, the transaction does not take effect after execution

Opened this issue · 2 comments

The code works fine when using the file address as the url, but when I use :memory: as the url, I find that commits don't work correctly.

Reproduction

repo

Problem Code

    const client = createClient({
      url: ":memory:",
    });

    const sqlText = `
CREATE TABLE subscriptions (
	id text PRIMARY KEY NOT NULL,
	name text NOT NULL,
	url text NOT NULL,
	updated_at integer DEFAULT (strftime('%s', 'now')) NOT NULL,
	created_at integer DEFAULT (strftime('%s', 'now')) NOT NULL
);`;

    const libsqlTx = await client.transaction();
    try {
      await libsqlTx.executeMultiple(sqlText);
      await libsqlTx.commit();
    } catch (err) {
      await libsqlTx.rollback();
      throw err;
    }

    const tables = await client.execute(
      `SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;`,
    );

    // tables.rows is empty array.

@libsql/client version: 0.4.0-pre.5

Maybe I'm using it the wrong way, I'm a little confused now.

The same is happening with me. Turning on the query logger shows the queries being executed but there are no tables in the database.

Tried both :memory: and file::memory.

I have the same problem using drizzle with turso. Especially annoying for integration tests.