@pi-r/mysql 0.6.0 → 0.6.2
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/README.md +2 -0
- package/client/index.js +28 -19
- package/package.json +4 -4
package/README.md
CHANGED
package/client/index.js
CHANGED
|
@@ -23,7 +23,7 @@ class MySQLPool extends DbPool {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
const POOL_STATE = {};
|
|
26
|
-
const POOL_UNUSED = ['ssl', 'connectTimeout', 'queueLimit', 'waitForConnections', 'connectionLimit', 'maxIdle', 'idleTimeout', 'enableKeepAlive', 'keepAliveInitialDelay'];
|
|
26
|
+
const POOL_UNUSED = ['ssl', 'connectTimeout', 'queueLimit', 'waitForConnections', 'connectionLimit', 'maxIdle', 'idleTimeout', 'enableKeepAlive', 'keepAliveInitialDelay', 'Promise'];
|
|
27
27
|
function removePoolProperties(credential) {
|
|
28
28
|
if (!credential.uuidKey) {
|
|
29
29
|
let result;
|
|
@@ -31,12 +31,12 @@ function removePoolProperties(credential) {
|
|
|
31
31
|
const attr = POOL_UNUSED[i];
|
|
32
32
|
if (attr in credential) {
|
|
33
33
|
result || (result = { ...credential });
|
|
34
|
-
if (attr
|
|
35
|
-
result[attr] = true;
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
34
|
+
if (attr !== 'ssl') {
|
|
38
35
|
delete result[attr];
|
|
39
36
|
}
|
|
37
|
+
else if ((0, types_1.isObject)(result.ssl)) {
|
|
38
|
+
result[attr] = true;
|
|
39
|
+
}
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
if (result) {
|
|
@@ -63,7 +63,11 @@ function isResultSetHeader(value) {
|
|
|
63
63
|
}
|
|
64
64
|
return false;
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
function getPoolKey(credential) {
|
|
67
|
+
if ((credential.host || credential.socketPath) && credential.user) {
|
|
68
|
+
return JSON.stringify(removeUUIDKey(credential));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
67
71
|
function setAuthentication(credential) {
|
|
68
72
|
const auth = (0, util_1.parseServerAuth)(credential);
|
|
69
73
|
credential.host || (credential.host = auth.hostname);
|
|
@@ -84,7 +88,7 @@ function setCredential(item) {
|
|
|
84
88
|
}
|
|
85
89
|
if (!credential.uri) {
|
|
86
90
|
const errors = [];
|
|
87
|
-
if (!credential.host) {
|
|
91
|
+
if (!credential.host && !credential.socketPath) {
|
|
88
92
|
errors.push('host');
|
|
89
93
|
}
|
|
90
94
|
if (!credential.user) {
|
|
@@ -99,18 +103,19 @@ function setCredential(item) {
|
|
|
99
103
|
return;
|
|
100
104
|
}
|
|
101
105
|
let username, password, pool;
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
pool
|
|
106
|
+
if ((0, types_1.isString)(usePool)) {
|
|
107
|
+
if (username = credential.user || credential.uri && (0, util_1.parseConnectionString)(credential.uri)?.username) {
|
|
108
|
+
[password, pool] = DbPool.validateKey(POOL_STATE, username, usePool);
|
|
109
|
+
if (pool) {
|
|
110
|
+
pool.add(item, password);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (!password) {
|
|
115
|
+
item.usePool = '';
|
|
106
116
|
return;
|
|
107
117
|
}
|
|
108
118
|
}
|
|
109
|
-
const poolKey = getPoolKey(credential);
|
|
110
|
-
if ((pool = POOL_STATE[poolKey]) && !pool.closed) {
|
|
111
|
-
pool.add(item);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
119
|
const config = this.getPoolConfig("mysql" /* STRINGS.MODULE_NAME */, password);
|
|
115
120
|
if (config) {
|
|
116
121
|
const { max, idle, queue_max, timeout } = config;
|
|
@@ -127,6 +132,11 @@ function setCredential(item) {
|
|
|
127
132
|
credential.connectTimeout ?? (credential.connectTimeout = timeout);
|
|
128
133
|
}
|
|
129
134
|
}
|
|
135
|
+
const poolKey = getPoolKey(credential);
|
|
136
|
+
if ((pool = POOL_STATE[poolKey]) && !pool.closed) {
|
|
137
|
+
pool.add(item);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
130
140
|
new MySQLPool(mysql.createPool(removeUUIDKey(credential)), poolKey, username && password ? { username, password } : undefined).add(item).parent = POOL_STATE;
|
|
131
141
|
}
|
|
132
142
|
exports.setCredential = setCredential;
|
|
@@ -249,10 +259,9 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
249
259
|
continue;
|
|
250
260
|
}
|
|
251
261
|
item.transactionState = 1 /* DB_TRANSACTION.ACTIVE */;
|
|
252
|
-
const
|
|
253
|
-
const cacheValue = renewCache ? { sessionKey, renewCache } : sessionKey;
|
|
262
|
+
const cacheValue = ignoreCache === undefined ? sessionKey : Array.isArray(ignoreCache) ? { sessionKey, exclusiveOf: ignoreCache } : { sessionKey, renewCache: ignoreCache === 0 };
|
|
254
263
|
let queryString = '';
|
|
255
|
-
if (
|
|
264
|
+
if (caching && ignoreCache !== true && !streamRow) {
|
|
256
265
|
queryString = Db.asString(query, true) + '_' + Db.asString(params, true);
|
|
257
266
|
const result = this.getQueryResult(source, removePoolProperties(credential), queryString, cacheValue);
|
|
258
267
|
if (ignoreCache !== 1) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/mysql",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "MySQL client driver for E-mc.",
|
|
5
5
|
"main": "client/index.js",
|
|
6
6
|
"types": "client/index.d.ts",
|
|
@@ -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.
|
|
25
|
-
"@e-mc/types": "^0.8.
|
|
26
|
-
"mysql2": "^3.
|
|
24
|
+
"@e-mc/db": "^0.8.2",
|
|
25
|
+
"@e-mc/types": "^0.8.2",
|
|
26
|
+
"mysql2": "^3.9.0"
|
|
27
27
|
}
|
|
28
28
|
}
|