mysql2 3.23.2 → 3.23.3-canary.20f732b
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/base/connection.js +21 -11
- package/lib/base/pool.js +5 -1
- package/lib/commands/query.js +6 -1
- package/package.json +19 -18
- package/typings/mysql/lib/Tracing.d.ts +4 -8
package/lib/base/connection.js
CHANGED
|
@@ -104,7 +104,8 @@ class BaseConnection extends EventEmitter {
|
|
|
104
104
|
this.handlePacket(p);
|
|
105
105
|
});
|
|
106
106
|
this.stream.on('data', (data) => {
|
|
107
|
-
|
|
107
|
+
// Server-side connections do not run ClientHandshake.
|
|
108
|
+
if (this.connectTimeout && this.config.isServer) {
|
|
108
109
|
Timers.clearTimeout(this.connectTimeout);
|
|
109
110
|
this.connectTimeout = null;
|
|
110
111
|
}
|
|
@@ -133,6 +134,10 @@ class BaseConnection extends EventEmitter {
|
|
|
133
134
|
if (!this.config.isServer) {
|
|
134
135
|
handshakeCommand = new Commands.ClientHandshake(this.config.clientFlags);
|
|
135
136
|
handshakeCommand.on('end', () => {
|
|
137
|
+
if (this.connectTimeout) {
|
|
138
|
+
Timers.clearTimeout(this.connectTimeout);
|
|
139
|
+
this.connectTimeout = null;
|
|
140
|
+
}
|
|
136
141
|
// this happens when handshake finishes early either because there was
|
|
137
142
|
// some fatal error or the server sent an error packet instead of
|
|
138
143
|
// an hello packet (for example, 'Too many connections' error)
|
|
@@ -271,13 +276,11 @@ class BaseConnection extends EventEmitter {
|
|
|
271
276
|
// connection handshake is special because we allow it to be implicit
|
|
272
277
|
// if error happened during handshake, but there are others commands in queue
|
|
273
278
|
// then bubble error to other commands and not to connection
|
|
274
|
-
} else if (
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
)
|
|
280
|
-
) {
|
|
279
|
+
} else if (!(
|
|
280
|
+
this._command &&
|
|
281
|
+
this._command.constructor === Commands.ClientHandshake &&
|
|
282
|
+
this._commands.length > 0
|
|
283
|
+
)) {
|
|
281
284
|
bubbleErrorToConnection = true;
|
|
282
285
|
}
|
|
283
286
|
while ((command = this._commands.shift())) {
|
|
@@ -583,7 +586,7 @@ class BaseConnection extends EventEmitter {
|
|
|
583
586
|
return cmd;
|
|
584
587
|
}
|
|
585
588
|
|
|
586
|
-
format(sql, values) {
|
|
589
|
+
format(sql, values, namedPlaceholders) {
|
|
587
590
|
if (typeof this.config.queryFormat === 'function') {
|
|
588
591
|
return this.config.queryFormat.call(
|
|
589
592
|
this,
|
|
@@ -596,6 +599,9 @@ class BaseConnection extends EventEmitter {
|
|
|
596
599
|
sql: sql,
|
|
597
600
|
values: values,
|
|
598
601
|
};
|
|
602
|
+
if (typeof namedPlaceholders !== 'undefined') {
|
|
603
|
+
opts.namedPlaceholders = namedPlaceholders;
|
|
604
|
+
}
|
|
599
605
|
this._resolveNamedPlaceholders(opts);
|
|
600
606
|
return SqlString.format(
|
|
601
607
|
opts.sql,
|
|
@@ -619,7 +625,10 @@ class BaseConnection extends EventEmitter {
|
|
|
619
625
|
|
|
620
626
|
_resolveNamedPlaceholders(options) {
|
|
621
627
|
let unnamed;
|
|
622
|
-
if (
|
|
628
|
+
if (typeof options.namedPlaceholders === 'undefined') {
|
|
629
|
+
options.namedPlaceholders = this.config.namedPlaceholders;
|
|
630
|
+
}
|
|
631
|
+
if (options.namedPlaceholders) {
|
|
623
632
|
if (Array.isArray(options.values)) {
|
|
624
633
|
// if an array is provided as the values, assume the conversion is not necessary.
|
|
625
634
|
// this allows the usage of unnamed placeholders even if the namedPlaceholders flag is enabled.
|
|
@@ -644,7 +653,8 @@ class BaseConnection extends EventEmitter {
|
|
|
644
653
|
this._resolveNamedPlaceholders(cmdQuery);
|
|
645
654
|
const rawSql = this.format(
|
|
646
655
|
cmdQuery.sql,
|
|
647
|
-
cmdQuery.values !== undefined ? cmdQuery.values : []
|
|
656
|
+
cmdQuery.values !== undefined ? cmdQuery.values : [],
|
|
657
|
+
cmdQuery.namedPlaceholders
|
|
648
658
|
);
|
|
649
659
|
cmdQuery.sql = rawSql;
|
|
650
660
|
|
package/lib/base/pool.js
CHANGED
|
@@ -254,7 +254,11 @@ class BasePool extends EventEmitter {
|
|
|
254
254
|
});
|
|
255
255
|
} catch (e) {
|
|
256
256
|
conn.release();
|
|
257
|
-
|
|
257
|
+
if (typeof cmdQuery.onResult === 'function') {
|
|
258
|
+
cmdQuery.onResult(e);
|
|
259
|
+
} else {
|
|
260
|
+
cmdQuery.emit('error', e);
|
|
261
|
+
}
|
|
258
262
|
}
|
|
259
263
|
});
|
|
260
264
|
return cmdQuery;
|
package/lib/commands/query.js
CHANGED
|
@@ -20,7 +20,12 @@ class Query extends Command {
|
|
|
20
20
|
this.sql = options.sql;
|
|
21
21
|
this.values = options.values;
|
|
22
22
|
this._queryOptions = options;
|
|
23
|
-
this.namedPlaceholders =
|
|
23
|
+
this.namedPlaceholders = Object.prototype.hasOwnProperty.call(
|
|
24
|
+
options,
|
|
25
|
+
'namedPlaceholders'
|
|
26
|
+
)
|
|
27
|
+
? options.namedPlaceholders
|
|
28
|
+
: undefined;
|
|
24
29
|
this.onResult = callback;
|
|
25
30
|
this.timeout = options.timeout;
|
|
26
31
|
this.queryTimeout = null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mysql2",
|
|
3
|
-
"version": "3.23.
|
|
3
|
+
"version": "3.23.3-canary.20f732b",
|
|
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",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"aws-ssl-profiles": "^1.1.2",
|
|
57
57
|
"denque": "^2.1.0",
|
|
58
58
|
"generate-function": "^2.3.1",
|
|
59
|
-
"iconv-lite": "^0.7.
|
|
59
|
+
"iconv-lite": "^0.7.3",
|
|
60
60
|
"long": "^5.3.2",
|
|
61
61
|
"lru.min": "^1.1.4",
|
|
62
62
|
"named-placeholders": "^1.1.6",
|
|
@@ -66,30 +66,31 @@
|
|
|
66
66
|
"@types/node": ">= 8"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@eslint/eslintrc": "^3.3.
|
|
70
|
-
"@eslint/js": "^
|
|
71
|
-
"@eslint/markdown": "^8.0.
|
|
69
|
+
"@eslint/eslintrc": "^3.3.6",
|
|
70
|
+
"@eslint/js": "^10.0.1",
|
|
71
|
+
"@eslint/markdown": "^8.0.3",
|
|
72
72
|
"@ianvs/prettier-plugin-sort-imports": "^4.7.1",
|
|
73
|
-
"@pokujs/multi-suite": "^1.0.
|
|
74
|
-
"@rollup/plugin-commonjs": "^29.0.
|
|
73
|
+
"@pokujs/multi-suite": "^1.0.2",
|
|
74
|
+
"@rollup/plugin-commonjs": "^29.0.3",
|
|
75
75
|
"@rollup/plugin-json": "^6.1.0",
|
|
76
76
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
77
|
-
"@types/node": "^26.
|
|
78
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
79
|
-
"@typescript-eslint/parser": "^8.
|
|
77
|
+
"@types/node": "^26.2.0",
|
|
78
|
+
"@typescript-eslint/eslint-plugin": "^8.66.0",
|
|
79
|
+
"@typescript-eslint/parser": "^8.66.0",
|
|
80
80
|
"assert-diff": "^3.0.4",
|
|
81
81
|
"benchmark": "^2.1.4",
|
|
82
|
-
"c8": "^
|
|
82
|
+
"c8": "^12.0.0",
|
|
83
83
|
"error-stack-parser": "^2.1.4",
|
|
84
|
+
"eslint": "^10.8.1",
|
|
84
85
|
"eslint-config-prettier": "^10.1.8",
|
|
85
86
|
"eslint-plugin-async-await": "^0.0.0",
|
|
86
|
-
"eslint-plugin-prettier": "^5.5.
|
|
87
|
-
"globals": "^17.
|
|
88
|
-
"poku": "^4.
|
|
87
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
88
|
+
"globals": "^17.9.0",
|
|
89
|
+
"poku": "^4.5.0",
|
|
89
90
|
"portfinder": "^1.0.38",
|
|
90
|
-
"prettier": "^3.
|
|
91
|
-
"rollup": "^4.
|
|
92
|
-
"tsx": "^4.
|
|
93
|
-
"typescript": "^
|
|
91
|
+
"prettier": "^3.9.6",
|
|
92
|
+
"rollup": "^4.62.4",
|
|
93
|
+
"tsx": "^4.23.11",
|
|
94
|
+
"typescript": "^6.0.3"
|
|
94
95
|
}
|
|
95
96
|
}
|
|
@@ -52,17 +52,13 @@ export declare function tracePromise<T extends object, R>(
|
|
|
52
52
|
): Promise<R>;
|
|
53
53
|
|
|
54
54
|
export declare const queryChannel:
|
|
55
|
-
|
|
56
|
-
| undefined;
|
|
55
|
+
TracingChannel<QueryTraceContext> | undefined;
|
|
57
56
|
export declare const executeChannel:
|
|
58
|
-
|
|
59
|
-
| undefined;
|
|
57
|
+
TracingChannel<ExecuteTraceContext> | undefined;
|
|
60
58
|
export declare const connectChannel:
|
|
61
|
-
|
|
62
|
-
| undefined;
|
|
59
|
+
TracingChannel<ConnectTraceContext> | undefined;
|
|
63
60
|
export declare const poolConnectChannel:
|
|
64
|
-
|
|
65
|
-
| undefined;
|
|
61
|
+
TracingChannel<PoolConnectTraceContext> | undefined;
|
|
66
62
|
|
|
67
63
|
export declare function getServerContext(config: {
|
|
68
64
|
socketPath?: string;
|