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

bun:sqlite truncates integers that cannot fit in a double #5661

Closed
JackTYM opened this issue Sep 18, 2023 · 3 comments · Fixed by #11887
Closed

bun:sqlite truncates integers that cannot fit in a double #5661

JackTYM opened this issue Sep 18, 2023 · 3 comments · Fixed by #11887
Labels
bug Something isn't working bun:sqlite Something to do with bun:sqlite

Comments

@JackTYM
Copy link

JackTYM commented Sep 18, 2023

What version of Bun is running?

1.0.2+37edd5a6e389265738e89265bcbdf2999cb81a49

What platform is your computer?

Linux 5.4.0-153-generic x86_64 x86_64

What steps can reproduce the bug?

Create a SQLite row with an INT or DOUBLE value over 53 bits
Select the row using .get() or .values() and print it
Resulting numbers are changed

What is the expected behavior?

The unchanged version of the number should be given

What do you see instead?

INT provided with value 990760989492400188
Object given with value 990760989492400100

Additional information

Seemingly happens from numbers over 53 bits

@JackTYM JackTYM added the bug Something isn't working label Sep 18, 2023
@JackTYM
Copy link
Author

JackTYM commented Sep 18, 2023

Current workaround is to just store text, but it is preferable if I could use normal integers or some sort of number data structure

@Prinzhorn
Copy link

#1536 #5256

@Jarred-Sumner Jarred-Sumner changed the title bun:sqlite changes numbers over int limit bun:sqlite truncates integers that cannot fit in a double Sep 18, 2023
@Electroid Electroid added the bun:sqlite Something to do with bun:sqlite label Sep 18, 2023
@nektro
Copy link
Contributor

nektro commented May 25, 2024

53 bits is the max of Number.MAX_SAFE_INTEGER for baseline javascript numbers which use the same data type as DOUBLE. (9007199254740991 for reference).

for clarification:
is the expectation that the number would then instead return in a BigInt instead? was the input already a BigInt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working bun:sqlite Something to do with bun:sqlite
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants