tursodatabase / tursodatabase/libsql
Typescript client can't insert into FTS5 tables
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 17.2k
- Forks
- 531
- Avg merge
- 1h 12m
- Merged PRs (30d)
- 1
Description
Hey there,
I'm trying to use the FTS5 extension with libsql, but the Typescript client is failing to insert anything into the table. Here is my code:
import { createClient } from "@libsql/client";
const client = createClient({
url: Bun.env.TURSO_LOCAL_FILE as string,
syncUrl: Bun.env.TURSO_DATABASE_URL as string,
authToken: Bun.env.TURSO_AUTH_TOKEN as string,
});
const contents = await Bun.file(
"./public/data.txt",
).text();
const chunks = contents.split("\n");
await client.execute(`DROP TABLE IF EXISTS docs;`);
await client.execute(
`CREATE VIRTUAL TABLE IF NOT EXISTS docs USING fts5 (chunk);`,
);
let stms = [];
for (let i = 0; i < chunks.length; i++) {
stms.push({
sql: `
INSERT INTO docs VALUES (:chunk);
`,
args: {
chunk: chunks[i],
},
});
}
const results = await client.batch(stms, "write");
console.log(results.length);
client.close();
When I run this code, this is what I get:
thread '<unnamed>' panicked at src/statement.rs:360:62:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
But if I instead use an HTTP client like postman, it all works fine. Am I doing something wrong here?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the provided TypeScript client reproduction using the FTS5 table and batch insert, then inspect src/statement.rs:360 where the panic is reported. Compare the failing embedded-client path with the working HTTP-client behavior; done means batch insertion completes without the Option::unwrap panic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100