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

Support 64bit numbers #139

Open
jackbow opened this issue Oct 8, 2024 · 3 comments
Open

Support 64bit numbers #139

jackbow opened this issue Oct 8, 2024 · 3 comments

Comments

@jackbow
Copy link

jackbow commented Oct 8, 2024

Or at least provide a warning somewhere I lost some time on this.

@DjDeveloperr
Copy link
Member

Have you tried the int64 option? https://github.com/denodrivers/sqlite3/blob/main/doc.md#options

@jackbow
Copy link
Author

jackbow commented Oct 9, 2024

Sorry about that! I had been switching between different drivers without looking at their individual options. Seems like the others must've had that on by default.

This actually makes me curious though - why not have int64 enabled by default?

@DjDeveloperr
Copy link
Member

DjDeveloperr commented Oct 9, 2024

Previously it was slow to return bigints from Deno FFI but now it’s fast. But I’m still not sure what to do in this case: SQLite3 tells us there is a column value of int type, we don’t know if it’s 32 bit or 64 bit so we always assume 32 bit unless int64 option is specified, in which case a bigint is returned only when a value is too big to fit in JS number. So the value becomes a union number | bigint - which is not exactly ideal because bigints are not compatible with numbers and would need special handling like checking the type before it’s used with something. We have three options to default to:

  • return a 32 bit truncated value as JS number
  • always assume 64 bit and return a bigint
  • return number if value fits in 52 bits for JS number else bigint

Another option would be to maybe always get a 64 bit value and truncate it to 52 bits for JS number, which is certainly better than 32 bit and will support majority use cases. BigInts are not a performance issue in recent Deno FFI update anymore so it won’t have any negative impacts.

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