Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RANDOM ROWIDs not working with the default IntMode: "number" #247

Open
abdurahmanshiine opened this issue Aug 11, 2024 · 0 comments
Open

Comments

@abdurahmanshiine
Copy link

abdurahmanshiine commented Aug 11, 2024

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?

@abdurahmanshiine abdurahmanshiine changed the title Random row ids not working with IntMode "number" Random row ids not working with IntMode "number" Aug 11, 2024
@abdurahmanshiine abdurahmanshiine changed the title Random row ids not working with IntMode "number" RANDOM ROWIDs not working with IntMode "number" Aug 11, 2024
@abdurahmanshiine abdurahmanshiine changed the title RANDOM ROWIDs not working with IntMode "number" RANDOM ROWIDs not working with IntMode: "number" Aug 11, 2024
@abdurahmanshiine abdurahmanshiine changed the title RANDOM ROWIDs not working with IntMode: "number" RANDOM ROWIDs not working with the default IntMode: "number" Aug 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant