-
Notifications
You must be signed in to change notification settings - Fork 39
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
Fix binding of +Infinity, -Infinity, -0, and extremely large number values #91
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for the PR! Looking pretty good so far. One thing I would like to change is to drop the -0
case.
SQLite serializes REAL values in tables in such a way that the -0
becomes a +0
regardless, so the check does not really do anything in practice. 😅
I left a couple of comments on how to structure the test cases as well. Happy to merge once those are addressed. 😅
LGTM 😍 Thank you @jeremyBanks for flagging this issue and the quick fix! |
* MySQL has been bumped to address the `v` prefix deprecation bug. * Sqlite has been bumped to take advantages upstream, see dyedgreen/deno-sqlite#94 and dyedgreen/deno-sqlite#91. * Bumped Dockerfile deno base from `1.4.4` to `1.5.2`, which is the latest available container at the time of this PR.
* MySQL has been bumped to address the `v` prefix deprecation bug. * Sqlite has been bumped to take advantages upstream, see dyedgreen/deno-sqlite#94 and dyedgreen/deno-sqlite#91. * Bumped Dockerfile deno base from `1.4.4` to `1.5.2`, which is the latest available container at the time of this PR.
* MySQL has been bumped to address the `v` prefix deprecation bug. * Sqlite has been bumped to take advantages upstream, see dyedgreen/deno-sqlite#94 and dyedgreen/deno-sqlite#91. * Bumped Dockerfile deno base from `1.4.4` to `1.5.2`, which is the latest available container at the time of this PR.
Closes #89
Fixes and adds tests the incorrect binding of
+Infinity
,-Infinity
,-0
, and extremely-largenumber
values, by only binding toINTEGER
for values which satisfy(Number.isSafeInteger(value) && !Object.is(value, -0))
, instead of(Math.floor(value) === value)
.In order to be preserve
-0
, we have to bind it as aREAL
instead of anINTEGER
like+0
. As far as I can tell, this should be harmless.A change in behaviour to call out: integer number values more massive than
MAX_SAFE_INTEGER
which could fit into anINTEGER
will now be stored asREAL
instead ofINTEGER
. I could go either way on this, but settled with this because you're usually not supposed to be treating values larger thanMAX_SAFE_INTEGER
as integers, even if they happen to fall on integer values.If you want to maintain them as
INTEGER
, I think you could change the condition to something like(Number.isFinite(value) && !Object.is(value, -0) && Math.floor(value) === value && -9_223_372_036_854_775_808 <= value && value <= 9_223_372_036_854_775_807)
instead.