-
Notifications
You must be signed in to change notification settings - Fork 2.5k
A bug fix for the Types.LONGLONG number range #1376
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
Conversation
According to MDN(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number#Integer_range_for_Number), Integer range for Number is -9007199254740992 to 9007199254740992. But In the original code, 1. There is no range for the negative value. 2. Can't print out 9007199254740993 value. Because of the gt sign at line 103 : Number(numberString) > IEEE_754_BINARY_64_PRECISION.
Thank you very much! In order to accept this pull request, you need to add tests. Since it is a bug fix, there needs to be at least one test that fails without your change and passes with your change. Please ping me when you add the test to the pull request and I'll take another look :)! |
@@ -1,7 +1,6 @@ | |||
var Types = require('../constants/types'); | |||
var Charsets = require('../constants/charsets'); | |||
var Field = require('./Field'); |
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.
Please re-align these statements now that the longest has been removed.
According to MDN(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number#Integer_range_for_Number), Integer range for Number is -9007199254740992 to 9007199254740992. But In the original code, 1. There is no range for the negative value. 2. Can't print out 9007199254740993 value. Because of the gt sign at line 103 : Number(numberString) > IEEE_754_BINARY_64_PRECISION.
According to MDN(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number#Integer_range_for_Number), Integer range for Number is -9007199254740992 to 9007199254740992. But In the original code, 1. There is no range for the negative value. 2. Can't print out 9007199254740993 value. Because of the gt sign at line 103 : Number(numberString) > IEEE_754_BINARY_64_PRECISION. Fixed, And re-aligned.
@dougwilson re-aligned the statements and bug fixed. Please take a look after being tested. |
Thanks, @Dinwy! I still need you to add tests for this. In order to accept this pull request, you need to add tests. Since it is a bug fix, there needs to be at least one test that fails without your change and passes with your change. Please ping me when you add the test to the pull request and I'll take another look :)! |
@dougwilson BeforeThere were two problems, A. Incorrect integer value comes out Before, the integer value that exceed Integer limits comes out incorrect. Also,
As you can see, Positive Integers that exceed Integer limits are parsed to string but Negative does not and that values are incorrect. B. Can't print out +- 9007199254740993 value. Because of the gt sign at line 103 : Number(numberString) > IEEE_754_BINARY_64_PRECISION,
FixedA. correct integer value comes out also the others.
B. Possible to print out +- 9007199254740993 value.
|
Hi @Dinwy, I understand that, but you need to write tests for that in our |
@dougwilson Oh, I'm sorry. I will add a test soon. |
# Conflicts: # lib/protocol/packets/RowDataPacket.js
mysqljs#1371 Fix bigint out of range problem
@dougwilson Could you please check this? |
Thanks for the contribution. Does this solve a known bug or did you find it yourself? I wasn't aware of it. |
@ronkorving This will solve a known bug #1371. |
@@ -149,7 +149,8 @@ function mergeTestConfig(config) { | |||
host : process.env.MYSQL_HOST, | |||
port : process.env.MYSQL_PORT, | |||
user : process.env.MYSQL_USER, | |||
password : process.env.MYSQL_PASSWORD | |||
password : process.env.MYSQL_PASSWORD, | |||
supportBigNumbers: true |
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.
Can you move this to just be set in the one test that needs it, instead of set in every single test? common.getTestConnection
accepts an optional first argument to provide test-specific configuration to merge with the common config here.
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.
I changed my code and I'm sorry for the additional trouble caused.
Fix mysqljs#1371 bigint error
@@ -150,7 +150,7 @@ function mergeTestConfig(config) { | |||
port : process.env.MYSQL_PORT, | |||
user : process.env.MYSQL_USER, | |||
password : process.env.MYSQL_PASSWORD | |||
}, config); | |||
}, config); |
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.
Needless whitespace change. This file should probably remain untouched in this PR.
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.
How could I miss this. Thanks.
Fix mysqljs#1371 bigint error
48ff604
to
e9dcd8a
Compare
According to MDN(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number#Integer_range_for_Number),
Integer range for Number is -9007199254740992 to 9007199254740992.
Bugs In the original code,