@pi-r/mysql 0.9.4 → 0.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/client/index.js CHANGED
@@ -51,7 +51,7 @@ function setCredential(item) {
51
51
  errors.push('user');
52
52
  }
53
53
  if (errors.length > 0) {
54
- throw (0, types_1.errorMessage)("mysql", 'Not defined - ' + errors.join(' | '));
54
+ throw (0, types_1.errorMessage)("mysql", "Invalid credentials", errors.join(', '));
55
55
  }
56
56
  }
57
57
  else {
@@ -76,9 +76,14 @@ function setCredential(item) {
76
76
  if (!usePool) {
77
77
  return;
78
78
  }
79
+ else if (credential.authPlugins || credential.stream || credential.authSwitchHandler) {
80
+ item.usePool = undefined;
81
+ return;
82
+ }
79
83
  let username, password, pool;
80
84
  if ((0, types_1.isString)(usePool)) {
81
- if (username = credential.user || credential.uri && (0, util_1.parseConnectionString)(credential.uri)?.username) {
85
+ username = credential.user || credential.uri && (0, util_1.parseConnectionString)(credential.uri)?.username;
86
+ if (username) {
82
87
  [password, pool] = DbPool.validateKey(POOL_STATE, username, usePool);
83
88
  if (pool) {
84
89
  pool.add(item, password);
package/client/pool.js CHANGED
@@ -4,6 +4,8 @@ const util_1 = require("@e-mc/db/util");
4
4
  const DbPool = require('@e-mc/db/pool');
5
5
  const POOL_ACTIVE = new WeakSet();
6
6
  class MySQLPool extends DbPool {
7
+ static CACHE_UNUSED = ['connectTimeout', 'queueLimit', 'waitForConnections', 'connectionLimit', 'maxIdle', 'idleTimeout', 'enableKeepAlive', 'keepAliveInitialDelay', 'Promise'];
8
+ static CACHE_IGNORE = ['authPlugins', 'authSwitchHandler', 'stream', 'infileStreamFactory'];
7
9
  static asString(credential) {
8
10
  if ((credential.host || credential.socketPath) && credential.user) {
9
11
  return JSON.stringify(this.removeUUIDKey(credential));
@@ -11,6 +13,9 @@ class MySQLPool extends DbPool {
11
13
  return super.asString(credential);
12
14
  }
13
15
  static sanitize(credential) {
16
+ if (!this.canCache(credential)) {
17
+ return;
18
+ }
14
19
  if (!POOL_ACTIVE.has(credential) || credential.uuidKey) {
15
20
  return credential;
16
21
  }
@@ -25,10 +30,10 @@ class MySQLPool extends DbPool {
25
30
  result.ssl = cert;
26
31
  }
27
32
  else if (Buffer.isBuffer(cert)) {
28
- result.ssl = cert.toString('utf-8');
33
+ result.ssl = cert.toString('utf8');
29
34
  }
30
35
  else if ((0, types_1.isArray)(cert)) {
31
- result.ssl = cert.reduce((a, b) => a + (Buffer.isBuffer(b) ? b.toString('utf-8') : b), '');
36
+ result.ssl = cert.reduce((a, b) => a + (Buffer.isBuffer(b) ? b.toString('utf8') : b), '');
32
37
  }
33
38
  else {
34
39
  result.ssl = "Unknown";
@@ -53,5 +58,4 @@ class MySQLPool extends DbPool {
53
58
  return !!this.client.pool._closed;
54
59
  }
55
60
  }
56
- MySQLPool.CACHE_UNUSED = ['connectTimeout', 'queueLimit', 'waitForConnections', 'connectionLimit', 'maxIdle', 'idleTimeout', 'enableKeepAlive', 'keepAliveInitialDelay', 'Promise'];
57
61
  module.exports = MySQLPool;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/mysql",
3
- "version": "0.9.4",
3
+ "version": "0.10.0",
4
4
  "description": "MySQL client driver for E-mc.",
5
5
  "main": "client/index.js",
6
6
  "types": "client/index.d.ts",
@@ -20,8 +20,8 @@
20
20
  "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/pi-r#readme",
22
22
  "dependencies": {
23
- "@e-mc/db": "^0.11.5",
24
- "@e-mc/types": "^0.11.5",
23
+ "@e-mc/db": "^0.12.0",
24
+ "@e-mc/types": "^0.12.0",
25
25
  "mysql2": "^3.14.0"
26
26
  }
27
27
  }