libsql-client-ts
libsql-client-ts copied to clipboard
`RANDOM ROWID`s not working with the default `IntMode: "number"`
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?