mysql2 3.9.8 → 3.10.0
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/commands/query.js
CHANGED
|
@@ -251,7 +251,7 @@ class Query extends Command {
|
|
|
251
251
|
if (this.onResult) {
|
|
252
252
|
this._rows[this._resultIndex].push(row);
|
|
253
253
|
} else {
|
|
254
|
-
this.emit('result', row);
|
|
254
|
+
this.emit('result', row, this._resultIndex);
|
|
255
255
|
}
|
|
256
256
|
return Query.prototype.row;
|
|
257
257
|
}
|
|
@@ -268,11 +268,11 @@ class Query extends Command {
|
|
|
268
268
|
stream._read = () => {
|
|
269
269
|
this._connection && this._connection.resume();
|
|
270
270
|
};
|
|
271
|
-
this.on('result', row => {
|
|
271
|
+
this.on('result', (row, resultSetIndex) => {
|
|
272
272
|
if (!stream.push(row)) {
|
|
273
273
|
this._connection.pause();
|
|
274
274
|
}
|
|
275
|
-
stream.emit('result', row); // replicate old emitter
|
|
275
|
+
stream.emit('result', row, resultSetIndex); // replicate old emitter
|
|
276
276
|
});
|
|
277
277
|
this.on('error', err => {
|
|
278
278
|
stream.emit('error', err); // Pass on any errors
|
package/lib/connection_config.js
CHANGED
|
@@ -65,7 +65,8 @@ const validOptions = {
|
|
|
65
65
|
idleTimeout: 1,
|
|
66
66
|
Promise: 1,
|
|
67
67
|
queueLimit: 1,
|
|
68
|
-
waitForConnections: 1
|
|
68
|
+
waitForConnections: 1,
|
|
69
|
+
jsonStrings: 1
|
|
69
70
|
};
|
|
70
71
|
|
|
71
72
|
class ConnectionConfig {
|
|
@@ -118,7 +119,7 @@ class ConnectionConfig {
|
|
|
118
119
|
this.trace = options.trace !== false;
|
|
119
120
|
this.stringifyObjects = options.stringifyObjects || false;
|
|
120
121
|
this.enableKeepAlive = options.enableKeepAlive !== false;
|
|
121
|
-
this.keepAliveInitialDelay = options.keepAliveInitialDelay
|
|
122
|
+
this.keepAliveInitialDelay = options.keepAliveInitialDelay;
|
|
122
123
|
if (
|
|
123
124
|
options.timezone &&
|
|
124
125
|
!/^(?:local|Z|[ +-]\d\d:\d\d)$/.test(options.timezone)
|
|
@@ -180,6 +181,7 @@ class ConnectionConfig {
|
|
|
180
181
|
};
|
|
181
182
|
this.connectAttributes = { ...defaultConnectAttributes, ...(options.connectAttributes || {})};
|
|
182
183
|
this.maxPreparedStatements = options.maxPreparedStatements || 16000;
|
|
184
|
+
this.jsonStrings = options.jsonStrings || false;
|
|
183
185
|
}
|
|
184
186
|
|
|
185
187
|
static mergeFlags(default_flags, user_flags) {
|
|
@@ -59,7 +59,7 @@ function readCodeFor(field, config, options, fieldNum) {
|
|
|
59
59
|
// Since for JSON columns mysql always returns charset 63 (BINARY),
|
|
60
60
|
// we have to handle it according to JSON specs and use "utf8",
|
|
61
61
|
// see https://github.com/sidorares/node-mysql2/issues/409
|
|
62
|
-
return 'JSON.parse(packet.readLengthCodedString("utf8"));';
|
|
62
|
+
return config.jsonStrings ? 'packet.readLengthCodedString("utf8")' : 'JSON.parse(packet.readLengthCodedString("utf8"));';
|
|
63
63
|
case Types.LONGLONG:
|
|
64
64
|
if (!supportBigNumbers) {
|
|
65
65
|
return unsigned
|
|
@@ -63,7 +63,7 @@ function readCodeFor(type, charset, encodingExpr, config, options) {
|
|
|
63
63
|
// Since for JSON columns mysql always returns charset 63 (BINARY),
|
|
64
64
|
// we have to handle it according to JSON specs and use "utf8",
|
|
65
65
|
// see https://github.com/sidorares/node-mysql2/issues/409
|
|
66
|
-
return 'JSON.parse(packet.readLengthCodedString("utf8"))';
|
|
66
|
+
return config.jsonStrings ? 'packet.readLengthCodedString("utf8")' : 'JSON.parse(packet.readLengthCodedString("utf8"))';
|
|
67
67
|
default:
|
|
68
68
|
if (charset === Charsets.BINARY) {
|
|
69
69
|
return 'packet.readLengthCodedBuffer()';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mysql2",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.0",
|
|
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",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"lint:tests": "npx prettier --check ./test",
|
|
13
13
|
"test": "poku --debug --include=\"test/esm,test/unit,test/integration\"",
|
|
14
14
|
"test:bun": "poku --debug --platform=\"bun\" --include=\"test/esm,test/unit,test/integration\"",
|
|
15
|
+
"test:deno": "deno run --allow-read --allow-env --allow-run npm:poku --debug --platform=\"deno\" --deno-allow=\"read,env,net,sys\" --deno-cjs=\".js,.cjs\" --include=\"test/esm,test/unit,test/integration\"",
|
|
15
16
|
"test:tsc-build": "cd \"test/tsc-build\" && npx tsc -p \"tsconfig.json\"",
|
|
16
17
|
"coverage-test": "c8 npm run test",
|
|
17
18
|
"benchmark": "node ./benchmarks/benchmark.js",
|
|
@@ -78,9 +79,8 @@
|
|
|
78
79
|
"eslint-config-prettier": "^9.0.0",
|
|
79
80
|
"eslint-plugin-async-await": "0.0.0",
|
|
80
81
|
"eslint-plugin-markdown": "^5.0.0",
|
|
81
|
-
"husky": "^9.0.2",
|
|
82
82
|
"lint-staged": "^15.0.1",
|
|
83
|
-
"poku": "^1.
|
|
83
|
+
"poku": "^1.14.0",
|
|
84
84
|
"portfinder": "^1.0.28",
|
|
85
85
|
"prettier": "^3.0.0",
|
|
86
86
|
"progress": "^2.0.3",
|
|
@@ -326,6 +326,13 @@ export interface ConnectionOptions {
|
|
|
326
326
|
authPlugins?: {
|
|
327
327
|
[key: string]: AuthPlugin;
|
|
328
328
|
};
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Force JSON to be returned as string
|
|
332
|
+
*
|
|
333
|
+
* (Default: false)
|
|
334
|
+
*/
|
|
335
|
+
jsonStrings?: boolean;
|
|
329
336
|
}
|
|
330
337
|
|
|
331
338
|
declare class Connection extends QueryableBase(ExecutableBase(EventEmitter)) {
|