mysql2 3.17.2 → 3.17.4

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.
@@ -29,10 +29,10 @@ class BasePoolConnection extends BaseConnection {
29
29
  this._pool.releaseConnection(this);
30
30
  }
31
31
 
32
- end() {
32
+ end(callback) {
33
33
  if (this.config.gracefulEnd) {
34
34
  this._removeFromPool();
35
- super.end();
35
+ super.end(callback);
36
36
 
37
37
  return;
38
38
  }
@@ -46,6 +46,9 @@ class BasePoolConnection extends BaseConnection {
46
46
  this.emit('warn', err);
47
47
  console.warn(err.message);
48
48
  this.release();
49
+ if (typeof callback === 'function') {
50
+ callback();
51
+ }
49
52
  }
50
53
 
51
54
  destroy() {
@@ -6,6 +6,32 @@
6
6
  const zlib = require('zlib');
7
7
  const PacketParser = require('./packet_parser.js');
8
8
 
9
+ class Queue {
10
+ constructor() {
11
+ this._queue = [];
12
+ this._running = false;
13
+ }
14
+
15
+ push(fn) {
16
+ this._queue.push(fn);
17
+ if (!this._running) {
18
+ this._running = true;
19
+ process.nextTick(() => this._next());
20
+ }
21
+ }
22
+
23
+ _next() {
24
+ const task = this._queue.shift();
25
+ if (!task) {
26
+ this._running = false;
27
+ return;
28
+ }
29
+ task({
30
+ done: () => process.nextTick(() => this._next()),
31
+ });
32
+ }
33
+ }
34
+
9
35
  function handleCompressedPacket(packet) {
10
36
  // eslint-disable-next-line consistent-this, no-invalid-this
11
37
  const connection = this;
@@ -117,11 +143,11 @@ function enableCompression(connection) {
117
143
  connection.writeUncompressed = connection.write;
118
144
  connection.write = writeCompressed;
119
145
 
120
- const seqqueue = require('seq-queue');
121
- connection.inflateQueue = seqqueue.createQueue();
122
- connection.deflateQueue = seqqueue.createQueue();
146
+ connection.inflateQueue = new Queue();
147
+ connection.deflateQueue = new Queue();
123
148
  }
124
149
 
125
150
  module.exports = {
126
151
  enableCompression: enableCompression,
152
+ Queue: Queue,
127
153
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mysql2",
3
- "version": "3.17.2",
3
+ "version": "3.17.4",
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",
@@ -8,17 +8,22 @@
8
8
  "scripts": {
9
9
  "lint": "eslint . && prettier --check .",
10
10
  "lint:fix": "eslint . --fix && prettier --write .",
11
- "test": "poku -d -r=verbose --sequential test/esm test/unit test/integration",
12
- "test:bun": "bun poku -d --sequential test/esm test/unit test/integration",
13
- "test:deno": "deno run --allow-read --allow-env --allow-run npm:poku -d --sequential --denoAllow=\"read,env,net,sys\" test/esm test/unit test/integration",
14
- "test:tsc-build": "cd \"test/tsc-build\" && npx tsc -p \"tsconfig.json\"",
11
+ "test": "npm run test:parallel && npm run test:global",
12
+ "test:parallel": "poku -c=\"poku.config.mjs\" test",
13
+ "test:global": "cross-env SUITE=global poku -c=\"poku.config.mjs\" test/global",
14
+ "test:bun": "npm run test:bun:parallel",
15
+ "test:bun:parallel": "bun poku -c=\"poku.config.mjs\" test",
16
+ "test:deno": "npm run test:deno:parallel && npm run test:deno:global",
17
+ "test:deno:parallel": "deno run --allow-read --allow-env --allow-run npm:poku@canary -c=\"poku.config.mjs\" test",
18
+ "test:deno:global": "cross-env SUITE=global deno run --allow-read --allow-env --allow-run npm:poku@canary -c=\"poku.config.mjs\" test/global",
15
19
  "test:docker:up": "docker compose -f test/docker-compose.yml up --abort-on-container-exit --remove-orphans",
16
20
  "test:docker:down": "docker compose -f test/docker-compose.yml down",
17
21
  "test:docker:node": "npm run test:docker:up -- node && npm run test:docker:down",
18
22
  "test:docker:bun": "npm run test:docker:up -- bun && npm run test:docker:down",
19
23
  "test:docker:deno": "npm run test:docker:up -- deno && npm run test:docker:down",
20
24
  "test:docker:coverage": "npm run test:docker:up -- coverage && npm run test:docker:down",
21
- "coverage-test": "c8 npm run test",
25
+ "test:coverage": "c8 npm test",
26
+ "typecheck": "cd \"test/tsc-build\" && tsc -p \"tsconfig.json\" && cd .. && tsc -p \"tsconfig.json\" --noEmit",
22
27
  "benchmark": "node ./benchmarks/benchmark.js",
23
28
  "wait-port": "wait-on"
24
29
  },
@@ -57,30 +62,31 @@
57
62
  "generate-function": "^2.3.1",
58
63
  "iconv-lite": "^0.7.2",
59
64
  "long": "^5.3.2",
60
- "lru.min": "^1.1.3",
65
+ "lru.min": "^1.1.4",
61
66
  "named-placeholders": "^1.1.6",
62
- "seq-queue": "^0.0.5",
63
67
  "sql-escaper": "^1.3.3"
64
68
  },
65
69
  "devDependencies": {
66
70
  "@eslint/eslintrc": "^3.3.3",
67
71
  "@eslint/js": "^9.39.2",
68
72
  "@eslint/markdown": "^7.5.1",
69
- "@types/node": "^25.0.9",
70
- "@typescript-eslint/eslint-plugin": "^8.53.0",
71
- "@typescript-eslint/parser": "^8.53.0",
73
+ "@ianvs/prettier-plugin-sort-imports": "^4.7.1",
74
+ "@types/node": "^25.3.0",
75
+ "@typescript-eslint/eslint-plugin": "^8.56.0",
76
+ "@typescript-eslint/parser": "^8.56.0",
72
77
  "assert-diff": "^3.0.4",
73
78
  "benchmark": "^2.1.4",
74
79
  "c8": "^10.1.3",
80
+ "cross-env": "^10.1.0",
75
81
  "error-stack-parser": "^2.1.4",
76
82
  "eslint-config-prettier": "^10.1.8",
77
83
  "eslint-plugin-async-await": "^0.0.0",
78
- "eslint-plugin-markdown": "^5.1.0",
79
84
  "eslint-plugin-prettier": "^5.5.5",
80
- "globals": "^17.0.0",
81
- "poku": "^3.0.2",
85
+ "globals": "^17.3.0",
86
+ "poku": "^3.0.3-canary.8f374795",
82
87
  "portfinder": "^1.0.38",
83
- "prettier": "^3.8.0",
88
+ "prettier": "^3.8.1",
89
+ "tsx": "^4.21.0",
84
90
  "typescript": "^5.9.3"
85
91
  }
86
92
  }
@@ -3,6 +3,18 @@ import { OkPacket, RowDataPacket, FieldPacket } from '../packets/index.js';
3
3
  import { Readable } from 'stream';
4
4
  import { TypeCast } from '../../parsers/typeCast.js';
5
5
 
6
+ export type QueryValues =
7
+ | string
8
+ | number
9
+ | bigint
10
+ | boolean
11
+ | Date
12
+ | null
13
+ | Blob
14
+ | Buffer
15
+ | ({} | null)[]
16
+ | { [key: string]: QueryValues };
17
+
6
18
  export interface QueryOptions {
7
19
  /**
8
20
  * The SQL for the query
@@ -12,7 +24,7 @@ export interface QueryOptions {
12
24
  /**
13
25
  * The values for the query
14
26
  */
15
- values?: any | any[] | { [param: string]: any };
27
+ values?: QueryValues;
16
28
 
17
29
  /**
18
30
  * This overrides the namedPlaceholders option set at the connection level.
@@ -1,5 +1,5 @@
1
1
  import { FieldPacket, QueryResult } from '../../packets/index.js';
2
- import { QueryOptions, QueryableConstructor } from '../Query.js';
2
+ import { QueryOptions, QueryableConstructor, QueryValues } from '../Query.js';
3
3
 
4
4
  export declare function ExecutableBase<T extends QueryableConstructor>(
5
5
  Base?: T
@@ -8,14 +8,14 @@ export declare function ExecutableBase<T extends QueryableConstructor>(
8
8
  execute<T extends QueryResult>(sql: string): Promise<[T, FieldPacket[]]>;
9
9
  execute<T extends QueryResult>(
10
10
  sql: string,
11
- values: any
11
+ values: QueryValues
12
12
  ): Promise<[T, FieldPacket[]]>;
13
13
  execute<T extends QueryResult>(
14
14
  options: QueryOptions
15
15
  ): Promise<[T, FieldPacket[]]>;
16
16
  execute<T extends QueryResult>(
17
17
  options: QueryOptions,
18
- values: any
18
+ values: QueryValues
19
19
  ): Promise<[T, FieldPacket[]]>;
20
20
  };
21
21
  } & T;