tursodatabase / tursodatabase/libsql-client-ts

Excecute only runs the first statement

Open
#132 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
576
Forks
69
PR merge metrics
No merged PRs in 30d

Description

Consider the following code

import { createClient } from "@libsql/client";

const file_name = process.cwd() + "/test.db";
const db_url = "file:" + file_name;

const db_client = createClient({
  url: db_url,
});

const rs = await db_client.execute(
  "CREATE TABLE a(a1 integer); CREATE TABLE b(b1 integer);"
);
console.log(rs);

Only the table a is created. The second create statement is silently ignored.

This is different from what better-sqlite3 does.
Supporting multiple statements would be useful for
reading sql statements form a file as in the example at

https://github.com/WiseLibs/better-sqlite3/blob/master/docs/api.md#execstring---this

const migration = fs.readFileSync('migrate-schema.sql', 'utf8');
db.exec(migration);

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the db_client.execute entry point shown in the issue and compare its behavior with the linked better-sqlite3 exec example. Done means a single input containing both CREATE statements creates both tables and supports the requested SQL-file migration use case.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, sqlite, typescript
Domain
database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.