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

sqlite3_column_double is lossy #325

Closed
AnyhowStep opened this issue Jan 10, 2020 · 5 comments · Fixed by #381
Closed

sqlite3_column_double is lossy #325

AnyhowStep opened this issue Jan 10, 2020 · 5 comments · Fixed by #381

Comments

@AnyhowStep
Copy link

AnyhowStep commented Jan 10, 2020

Running the following statement,

SELECT 1.7976931348623157e+308

On this,
http://kripken.github.io/sql.js/examples/GUI/

Gives me this result set,

1.7976931348623157e+308
Infinity

I know it's not supposed to be Infinity because of this DB Fiddle,

Schema (SQLite v3.30)


Query 1

SELECT 1.7976931348623157e+308;
1.7976931348623157e+308
1.7976931348623157e+308

View on DB Fiddle


This isn't the only example of doubles being lossy for some reason unknown to me.
I've seen cases where I had decimal places being cut off, numbers being rounded up and down, etc.
Is there a workaround for this?

@AnyhowStep
Copy link
Author

I wonder if it has to do with this flag,
https://github.com/kripken/sql.js/blob/142d9de79be98d58368b440f3160935b73ce3154/Makefile#L22

Is there a different flag that needs to be set?

@AnyhowStep
Copy link
Author

AnyhowStep commented Jan 11, 2020

Not quite related, but I'm not sure if I should open a new issue.

This query,

SELECT 1.7976931348623157e+308 * 1.7976931348623157e+308

Should return null (as in regular SQLite).

Infinity, -Infinity, and NaN are not valid SQL double values

@lovasoa
Copy link
Member

lovasoa commented Jan 11, 2020

SELECT 1.7976931348623157e+308 * 1.7976931348623157e+308

Should return null (as in regular SQLite).

I just tried it on my computer :

$ sqlite3 --version
3.22.0 2018-01-22 18:45:57 0c55d179733b46d8d0ba4d88e01a25e10677046ee3da1d5b1581e86726f2alt1
$ echo 'SELECT 1.7976931348623157e+308 * 1.7976931348623157e+308;' | sqlite3 
Inf

@AnyhowStep
Copy link
Author

Ah, right. I forgot DB Fiddle returns results as a JSON string, and Inf, NaN, -Inf become null. Sorry about that

brodycj pushed a commit to brodycj/sql.js that referenced this issue Feb 3, 2020
brodycj pushed a commit to brodycj/sql.js that referenced this issue Feb 3, 2020
brodycj pushed a commit to brodycj/sql.js that referenced this issue Feb 3, 2020
brodycj pushed a commit to brodycj/sql.js that referenced this issue Feb 3, 2020
brodycj pushed a commit to brodycj/sql.js that referenced this issue Feb 3, 2020
in order to resolve the long double issue discussed in sql-js#325
@brodycj
Copy link
Contributor

brodycj commented Feb 3, 2020

I wonder if it has to do with this flag,
https://github.com/kripken/sql.js/blob/142d9de79be98d58368b440f3160935b73ce3154/Makefile#L22

Yes. Removing this flag does seem to resolve the issue for me, both in a new test case and in my local build of the GUI. I just proposed a new test case in draft PR #336, fix PR is coming next.

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

Successfully merging a pull request may close this issue.

3 participants