mysql2 3.21.0 → 3.21.1-canary.295264b2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -155,21 +155,17 @@ class Packet {
155
155
  readInt64() {
156
156
  const word0 = this.readInt32();
157
157
  const word1 = this.readInt32();
158
- let res = new Long(word0, word1, true);
158
+ const res = new Long(word0, word1, true);
159
159
  const resNumber = res.toNumber();
160
- const resString = res.toString();
161
- res = resNumber.toString() === resString ? resNumber : resString;
162
- return res;
160
+ return Number.isSafeInteger(resNumber) ? resNumber : res.toString();
163
161
  }
164
162
 
165
163
  readSInt64() {
166
164
  const word0 = this.readInt32();
167
165
  const word1 = this.readInt32();
168
- let res = new Long(word0, word1, false);
166
+ const res = new Long(word0, word1, false);
169
167
  const resNumber = res.toNumber();
170
- const resString = res.toString();
171
- res = resNumber.toString() === resString ? resNumber : resString;
172
- return res;
168
+ return Number.isSafeInteger(resNumber) ? resNumber : res.toString();
173
169
  }
174
170
 
175
171
  isEOF() {
@@ -223,8 +219,10 @@ class Packet {
223
219
  res = new Long(word0, word1, !signed); // Long need unsigned
224
220
  const resNumber = res.toNumber();
225
221
  const resString = res.toString();
226
- res = resNumber.toString() === resString ? resNumber : resString;
227
- return bigNumberStrings ? resString : res;
222
+ if (bigNumberStrings || !Number.isSafeInteger(resNumber)) {
223
+ return resString;
224
+ }
225
+ return resNumber;
228
226
  }
229
227
 
230
228
  console.trace();
@@ -458,7 +456,7 @@ class Packet {
458
456
  if (numDigits >= 15) {
459
457
  str = this.readString(end - this.offset, 'binary');
460
458
  result = parseInt(str, 10);
461
- if (result.toString() === str) {
459
+ if (Number.isSafeInteger(sign * result)) {
462
460
  return sign * result;
463
461
  }
464
462
  return sign === -1 ? `-${str}` : str;
@@ -480,11 +478,10 @@ class Packet {
480
478
  if (!supportBigNumbers) {
481
479
  return num;
482
480
  }
483
- str = this.buffer.toString('ascii', start, end);
484
- if (num.toString() === str) {
481
+ if (Number.isSafeInteger(num)) {
485
482
  return num;
486
483
  }
487
- return str;
484
+ return this.buffer.toString('ascii', start, end);
488
485
  }
489
486
 
490
487
  // note that if value of inputNumberAsString is bigger than MAX_SAFE_INTEGER
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mysql2",
3
- "version": "3.21.0",
3
+ "version": "3.21.1-canary.295264b2",
4
4
  "description": "fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS",
5
5
  "main": "index.js",
6
6
  "typings": "typings/mysql/index",