@pi-r/mysql 0.6.2 → 0.6.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.
package/client/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import type { IDb } from '@e-mc/types/lib';
2
- import type { MySQLCredential, MySQLDataSource } from '@e-mc/types/lib/db';
3
2
 
4
3
  import type { IDbSourceClient } from '@e-mc/db/types';
5
4
 
5
+ import type { MySQLCredential, MySQLDataSource } from '../types';
6
+
6
7
  declare const MySQL: IDbSourceClient<MySQLDataSource> & {
7
8
  setAuthentication(this: IDb, credential: MySQLCredential): void;
8
9
  };
package/client/index.js CHANGED
@@ -24,8 +24,9 @@ class MySQLPool extends DbPool {
24
24
  }
25
25
  const POOL_STATE = {};
26
26
  const POOL_UNUSED = ['ssl', 'connectTimeout', 'queueLimit', 'waitForConnections', 'connectionLimit', 'maxIdle', 'idleTimeout', 'enableKeepAlive', 'keepAliveInitialDelay', 'Promise'];
27
+ const POOL_ACTIVE = new WeakSet();
27
28
  function removePoolProperties(credential) {
28
- if (!credential.uuidKey) {
29
+ if (!credential.uuidKey && POOL_ACTIVE.has(credential)) {
29
30
  let result;
30
31
  for (let i = 0, length = POOL_UNUSED.length; i < length; ++i) {
31
32
  const attr = POOL_UNUSED[i];
@@ -180,6 +181,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
180
181
  if (mysqlPool) {
181
182
  pools.push(client = await mysqlPool.getConnection());
182
183
  item.transactionState &= ~64 /* DB_TRANSACTION.AUTH */;
184
+ POOL_ACTIVE.add(credential);
183
185
  return client;
184
186
  }
185
187
  const pool = item.usePool && DbPool.findKey(POOL_STATE, item.usePool, getPoolKey(credential), ...connectOnce ? [item, batch[0]] : [item]);
@@ -190,6 +192,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
190
192
  mysqlPool = pool;
191
193
  }
192
194
  pool.connected = true;
195
+ POOL_ACTIVE.add(credential);
193
196
  }
194
197
  catch (err) {
195
198
  let close;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/mysql",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "MySQL client driver for E-mc.",
5
5
  "main": "client/index.js",
6
6
  "types": "client/index.d.ts",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "https://github.com/anpham6/pi-r.git",
12
+ "url": "git+https://github.com/anpham6/pi-r.git",
13
13
  "directory": "src/db/mysql"
14
14
  },
15
15
  "keywords": [
@@ -21,8 +21,8 @@
21
21
  "license": "MIT",
22
22
  "homepage": "https://github.com/anpham6/pi-r#readme",
23
23
  "dependencies": {
24
- "@e-mc/db": "^0.8.2",
25
- "@e-mc/types": "^0.8.2",
26
- "mysql2": "^3.9.0"
24
+ "@e-mc/db": "^0.8.4",
25
+ "@e-mc/types": "^0.8.4",
26
+ "mysql2": "^3.9.1"
27
27
  }
28
28
  }