@pi-r/mariadb 0.2.0 → 0.2.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/client/index.js +21 -6
- package/package.json +2 -2
package/client/index.js
CHANGED
|
@@ -21,9 +21,25 @@ class MariaDBPool extends DbPool {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
const POOL_STATE = {};
|
|
24
|
+
const POOL_UNUSED = ['ssl', 'connectTimeout', 'socketTimeout', 'compress', 'keepAliveDelay', 'acquireTimeout', 'connectionLimit', 'idleTimeout', 'initializationTimeout', 'minDelayValidation', 'minimumIdle', 'resetAfterUse', 'noControlAfterUse', 'leakDetectionTimeout'];
|
|
24
25
|
function removePoolProperties(credential) {
|
|
25
|
-
if (!credential.uuidKey
|
|
26
|
-
|
|
26
|
+
if (!credential.uuidKey) {
|
|
27
|
+
let result;
|
|
28
|
+
for (let i = 0, length = POOL_UNUSED.length; i < length; ++i) {
|
|
29
|
+
const attr = POOL_UNUSED[i];
|
|
30
|
+
if (attr in credential) {
|
|
31
|
+
result || (result = { ...credential });
|
|
32
|
+
if (attr === 'ssl' && (0, types_1.isObject)(result[attr])) {
|
|
33
|
+
result[attr] = true;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
delete result[attr];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (result) {
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
27
43
|
}
|
|
28
44
|
return credential;
|
|
29
45
|
}
|
|
@@ -31,7 +47,6 @@ function removeUUIDKey(credential) {
|
|
|
31
47
|
if ('uuidKey' in credential) {
|
|
32
48
|
credential = { ...credential };
|
|
33
49
|
delete credential.uuidKey;
|
|
34
|
-
return credential;
|
|
35
50
|
}
|
|
36
51
|
return credential;
|
|
37
52
|
}
|
|
@@ -239,7 +254,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
239
254
|
}
|
|
240
255
|
}
|
|
241
256
|
}
|
|
242
|
-
if (onceCredential && parallel
|
|
257
|
+
if (onceCredential && parallel) {
|
|
243
258
|
try {
|
|
244
259
|
mariaDBClient = await getConnection(item, onceCredential);
|
|
245
260
|
}
|
|
@@ -283,13 +298,13 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
283
298
|
}
|
|
284
299
|
else {
|
|
285
300
|
this.add(item, 4 /* DB_TRANSACTION.COMMIT */);
|
|
286
|
-
resolve(!error ? this.setQueryResult(source, removePoolProperties(credential), queryString, rows, cacheValue) : rows);
|
|
301
|
+
resolve(!error ? this.setQueryResult(source, removePoolProperties(credential), queryString, rows, cacheValue) : rows.length ? rows : null);
|
|
287
302
|
}
|
|
288
303
|
}
|
|
289
304
|
else {
|
|
290
305
|
const rows = await client.query(query, params);
|
|
291
306
|
this.add(item, 4 /* DB_TRANSACTION.COMMIT */);
|
|
292
|
-
resolve(
|
|
307
|
+
resolve((0, types_1.isArray)(rows) ? this.setQueryResult(source, removePoolProperties(credential), queryString, rows, cacheValue) : null);
|
|
293
308
|
}
|
|
294
309
|
}
|
|
295
310
|
catch (err) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/mariadb",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "MariaDB client driver for E-mc.",
|
|
5
5
|
"main": "client/index.js",
|
|
6
6
|
"types": "client/index.d.ts",
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@e-mc/db": "^0.5.3",
|
|
25
25
|
"@e-mc/types": "^0.5.3",
|
|
26
|
-
"mariadb": "^3.
|
|
26
|
+
"mariadb": "^3.2.0"
|
|
27
27
|
}
|
|
28
28
|
}
|