Skip to content

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

Closed
wants to merge 16 commits into from
Closed

Conversation

Dinwy
Copy link
Contributor

@Dinwy Dinwy commented Mar 29, 2016

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,

  1. There is no range for the negative values.
  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.
@dougwilson
Copy link
Member

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');
Copy link
Member

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.

Dinwy added 3 commits March 30, 2016 02:32
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.
@Dinwy
Copy link
Contributor Author

Dinwy commented Mar 29, 2016

@dougwilson re-aligned the statements and bug fixed. Please take a look after being tested.

@dougwilson
Copy link
Member

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 :)!

@Dinwy
Copy link
Contributor Author

Dinwy commented Mar 29, 2016

@dougwilson
on the issue #1371 ,

Before

There were two problems,

A. Incorrect integer value comes out

Before, the integer value that exceed Integer limits comes out incorrect.
Already being adressed on #1371 ,
-185395119379775634 automatically changed to -185395119379775650.

Also,

[{"id":1,"big":"9223372036854775807"},{"id":2,"big":-9223372036854776000},
{"id":3,"big":"1111111111111111111"},{"id":4,"big":-1111111111111111200}]

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,
+-9007199254740993 changed to +-9007199254740992(max/min value of integer).

{"id":4,"big":9007199254740992},{"id":5,"big":-9007199254740992}]

Fixed

A. correct integer value comes out
-185395119379775634 comes out correctly.
{"id":5,"big":"-185395119379775634"}]

also the others.

[{"id":1,"big":"9223372036854775807"},{"id":2,"big":"-9223372036854775807"},
{"id":3,"big":"1111111111111111111"},{"id":4,"big":"-1111111111111111111"}]

B. Possible to print out +- 9007199254740993 value.

{"id":4,"big":"9007199254740993"},{"id":5,"big":"-9007199254740993"}]

@dougwilson
Copy link
Member

Hi @Dinwy, I understand that, but you need to write tests for that in our tests/ folder, please. I can do it if you can't, but cannot make promises on the timeline. 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 :)!

@Dinwy
Copy link
Contributor Author

Dinwy commented Mar 29, 2016

@dougwilson Oh, I'm sorry. I will add a test soon.

@Dinwy
Copy link
Contributor Author

Dinwy commented Mar 30, 2016

@dougwilson Could you please check this?

@ronkorving
Copy link
Contributor

Thanks for the contribution. Does this solve a known bug or did you find it yourself? I wasn't aware of it.

@Dinwy
Copy link
Contributor Author

Dinwy commented Apr 5, 2016

@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
Copy link
Member

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.

Copy link
Contributor Author

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.

@@ -150,7 +150,7 @@ function mergeTestConfig(config) {
port : process.env.MYSQL_PORT,
user : process.env.MYSQL_USER,
password : process.env.MYSQL_PASSWORD
}, config);
}, config);
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@dougwilson dougwilson force-pushed the master branch 2 times, most recently from 48ff604 to e9dcd8a Compare May 7, 2016 02:46
@dougwilson dougwilson closed this in 8c4df89 May 8, 2016
dougwilson pushed a commit that referenced this pull request May 8, 2016
dougwilson pushed a commit that referenced this pull request May 8, 2016
dougwilson pushed a commit that referenced this pull request May 8, 2016
dveeden pushed a commit to dveeden/mysql that referenced this pull request Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants