libsql-client-ts icon indicating copy to clipboard operation
libsql-client-ts copied to clipboard

Fix the local database implementation of Client.batch()

Open penberg opened this issue 2 years ago • 1 comments

We currently implement batch() by issuing every statement separately. Let's switch to libSQL batch interface instead (we need to expose it in libsql first).

penberg avatar Nov 01 '23 09:11 penberg

This might be related.. I'm initialising the DB on server start like this:

  const initSql = readFileSync(dir + '/init_sqlite.sql', 'utf8')
  const res = await client.execute(initSql)

The init file contains multiple satements like CREATE TABLE IF NOT EXISTS blabla..

This works locally, so when createClient gets url parameter with file:..., but when using Turso and giving url with libsql://turso... and authToken, it gives an error LibsqlError: SQL_MANY_STATEMENTS: SQL string contains more than one statement

Expected behaviour is consistency i.e. either both ways fail or succeed.

pihvi avatar Mar 31 '24 19:03 pihvi