@pi-r/mariadb 0.2.2 → 0.2.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.js +17 -2
- package/package.json +1 -1
package/client/index.js
CHANGED
|
@@ -50,6 +50,10 @@ function removeUUIDKey(credential) {
|
|
|
50
50
|
}
|
|
51
51
|
return credential;
|
|
52
52
|
}
|
|
53
|
+
function isOkPacket(value) {
|
|
54
|
+
const result = Array.isArray(value) ? value[0] : value;
|
|
55
|
+
return !!result && !Array.isArray(result) && result.constructor.name === 'OkPacket';
|
|
56
|
+
}
|
|
53
57
|
const getPoolKey = (credential) => (credential.host || '') + '_' + (credential.port || '3306') + (credential.user || '') + '_' + (credential.password || '') + '_' + (credential.database || '') + '_' + (credential.rowsAsArray ? '1' : '0');
|
|
54
58
|
function setAuthentication(credential) {
|
|
55
59
|
const auth = (0, util_1.parseServerAuth)(credential);
|
|
@@ -267,7 +271,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
267
271
|
tasks[i] = new Promise(async (resolve, reject) => {
|
|
268
272
|
let commandType;
|
|
269
273
|
try {
|
|
270
|
-
const client = mariaDBClient || await getConnection(item, credential);
|
|
274
|
+
const client = mariaDBClient || await getConnection(item, removeUUIDKey(credential));
|
|
271
275
|
if (mariaDBClient && parallel) {
|
|
272
276
|
mariaDBClient = undefined;
|
|
273
277
|
}
|
|
@@ -304,7 +308,18 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
304
308
|
else {
|
|
305
309
|
const rows = await client.query(query, params);
|
|
306
310
|
this.add(item, 4 /* DB_TRANSACTION.COMMIT */);
|
|
307
|
-
|
|
311
|
+
if ((0, types_1.isArray)(rows)) {
|
|
312
|
+
const [row1, row2] = rows;
|
|
313
|
+
if (rows.length === 2 && Array.isArray(row1) && !Array.isArray(row2) && isOkPacket(row2)) {
|
|
314
|
+
resolve(row1);
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
resolve(!isOkPacket(row1) ? this.setQueryResult(source, removePoolProperties(credential), queryString, rows, cacheValue) : null);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
resolve(null);
|
|
322
|
+
}
|
|
308
323
|
}
|
|
309
324
|
}
|
|
310
325
|
catch (err) {
|