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.
- package/lib/packets/packet.js +11 -14
- package/package.json +1 -1
package/lib/packets/packet.js
CHANGED
|
@@ -155,21 +155,17 @@ class Packet {
|
|
|
155
155
|
readInt64() {
|
|
156
156
|
const word0 = this.readInt32();
|
|
157
157
|
const word1 = this.readInt32();
|
|
158
|
-
|
|
158
|
+
const res = new Long(word0, word1, true);
|
|
159
159
|
const resNumber = res.toNumber();
|
|
160
|
-
|
|
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
|
-
|
|
166
|
+
const res = new Long(word0, word1, false);
|
|
169
167
|
const resNumber = res.toNumber();
|
|
170
|
-
|
|
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
|
-
|
|
227
|
-
|
|
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 (
|
|
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
|
-
|
|
484
|
-
if (num.toString() === str) {
|
|
481
|
+
if (Number.isSafeInteger(num)) {
|
|
485
482
|
return num;
|
|
486
483
|
}
|
|
487
|
-
return
|
|
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