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

JS not able to represent long integer with Number #3

Closed
AkshayBhimani opened this issue May 30, 2023 · 2 comments
Closed

JS not able to represent long integer with Number #3

AkshayBhimani opened this issue May 30, 2023 · 2 comments

Comments

@AkshayBhimani
Copy link

When trying to fetch data from Turso DB where one table column has long integer (for me integer with 19 digit ). It is giving error cannot be safely represented as a JavaScript number

Full trace :

RangeError: Received integer 1658936802800002836 which cannot be safely represented as a JavaScript number
    at valueFromProto (/home/user/project/node_modules/@libsql/hrana-client/lib-esm/value.js:46:19)
    at rowFromProto (/home/user/project/node_modules/@libsql/hrana-client/lib-esm/result.js:37:23)
    at /home/user/project/node_modules/@libsql/hrana-client/lib-esm/result.js:13:44
    at Array.map (<anonymous>)
    at rowsResultFromProto (/home/user/project/node_modules/@libsql/hrana-client/lib-esm/result.js:13:33)
    at Object.responseCallback (/home/user/project/node_modules/@libsql/hrana-client/lib-esm/stream.js:41:30)
    at Client.#handleMsg (/home/user/project/node_modules/@libsql/hrana-client/lib-esm/client.js:213:31)
    at Client.#onSocketMessage (/home/user/project/node_modules/@libsql/hrana-client/lib-esm/client.js:178:18)
    at /home/user/project/node_modules/@libsql/hrana-client/lib-esm/client.js:53:66
    at /home/user/project/node_modules/@miniflare/shared/src/event.ts:29:9
TypeError: WebSocket already closed
    at _WebSocket.[kClose] (/home/user/project/node_modules/@miniflare/web-sockets/src/websocket.ts:298:38)
    at _WebSocket.close (/home/user/project/node_modules/@miniflare/web-sockets/src/websocket.ts:291:10)
    at Client.#setClosed (/home/user/project/node_modules/@libsql/hrana-client/lib-esm/client.js:165:22)
    at Client.#onSocketMessage (/home/user/project/node_modules/@libsql/hrana-client/lib-esm/client.js:182:18)
    at /home/user/project/node_modules/@libsql/hrana-client/lib-esm/client.js:53:66
    at /home/user/project/node_modules/@miniflare/shared/src/event.ts:29:9
    at /home/user/project/node_modules/@miniflare/web-sockets/src/websocket.ts:189:38
    at AsyncLocalStorage.run (node:async_hooks:330:14)
@honzasp
Copy link
Contributor

honzasp commented May 30, 2023

Hi, thank you for your bug report! :) This is related to an existing issue:
tursodatabase/libsql-client-ts#32

Basically, this is expected default behavior: we chose to convert SQLite integers to JavaScript numbers by default, but we don't yet provide a way to opt into using bigints instead.

What would be your preferred solution? Would you prefer if we returned integers as bigints by default?

@honzasp
Copy link
Contributor

honzasp commented Jun 22, 2023

Fixed in version 0.4.2, you can use Client.intMode or Stream.intMode to choose the JavaScript representation of SQLite integers: either number, bigint or string.

@honzasp honzasp closed this as completed Jun 22, 2023
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

2 participants