tursodatabase / tursodatabase/libsql-client-ts
`RANDOM ROWID`s not working with the default `IntMode: "number"`
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 576
- Forks
- 69
- PR merge metrics
- No merged PRs in 30d
Description
Hi there,
I'm using random row ids as primary keys, my schema goes something like this:
CREATE TABLE users (
id INTEGER PRIMARY KEY NOT NULL,
-- ...
) STRICT, RANDOM ROWID;
And I have a query that looks like this (mind you that I'm using the default IntMode: "number" here):
const conn = createClient(connOptions)
const sql = `
SELECT *
FROM users
WHERE email = ?;
`
const resp = await conn.execute({ sql, args: [email] })
The problem is when I run the query this error is thrown:
245 | function valueFromSql(sqlValue, intMode) {
246 | if (typeof sqlValue === "bigint") {
247 | if (intMode === "number") {
248 | if (sqlValue < minSafeBigint || sqlValue > maxSafeBigint) {
249 | throw new RangeError("Received integer which cannot be safely re
presented as a JavaScript number");
^
RangeError: Received integer which cannot be safely represented as a JavaScript number
I tried changing the IntMode to bigint, but it converts INTEGER to bigint. Any idea what I'm doing wrong?
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
Start at the valueFromSql entry point shown in the stack trace and trace how the default IntMode: "number" handles INTEGER results from the RANDOM ROWID schema. Compare that path with IntMode: "bigint" and use the createClient/execute example to verify the intended result conversion without the reported RangeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sqlite, typescript
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100