@pi-r/mariadb 0.2.4 → 0.2.8
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/LICENSE +1 -1
- package/README.md +4 -2
- package/client/index.js +14 -14
- package/package.json +5 -5
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright 2023
|
|
1
|
+
Copyright 2023 Mile Square Park
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
package/README.md
CHANGED
package/client/index.js
CHANGED
|
@@ -95,7 +95,7 @@ function setCredential(item) {
|
|
|
95
95
|
errors.push('user');
|
|
96
96
|
}
|
|
97
97
|
if (errors.length) {
|
|
98
|
-
throw (0, types_1.errorMessage)("mariadb"
|
|
98
|
+
throw (0, types_1.errorMessage)("mariadb", 'Not defined - ' + errors.join(' | '));
|
|
99
99
|
}
|
|
100
100
|
const usePool = item.usePool;
|
|
101
101
|
if (usePool) {
|
|
@@ -109,8 +109,8 @@ function setCredential(item) {
|
|
|
109
109
|
}
|
|
110
110
|
const poolKey = getPoolKey(credential);
|
|
111
111
|
if (!(pool = POOL_STATE[poolKey]) || pool.closed) {
|
|
112
|
-
const { createPool } = require("mariadb"
|
|
113
|
-
const config = this.getPoolConfig("mariadb"
|
|
112
|
+
const { createPool } = require("mariadb");
|
|
113
|
+
const config = this.getPoolConfig("mariadb", password);
|
|
114
114
|
if (config) {
|
|
115
115
|
const { max, idle } = config;
|
|
116
116
|
if (max > 0) {
|
|
@@ -137,7 +137,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
137
137
|
if (length === 0) {
|
|
138
138
|
return [];
|
|
139
139
|
}
|
|
140
|
-
const db = require("mariadb"
|
|
140
|
+
const db = require("mariadb");
|
|
141
141
|
let parallel, connectOnce, errorQuery, sessionKey, outCacheMiss;
|
|
142
142
|
if ((0, types_1.isPlainObject)(options)) {
|
|
143
143
|
({ parallel, connectOnce, errorQuery, sessionKey, outCacheMiss } = options);
|
|
@@ -158,17 +158,17 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
158
158
|
if (!parallel) {
|
|
159
159
|
outResult || (outResult = new Array(length));
|
|
160
160
|
}
|
|
161
|
-
const caching = this.hasCache("mariadb"
|
|
161
|
+
const caching = this.hasCache("mariadb", sessionKey);
|
|
162
162
|
const tasks = new Array(length);
|
|
163
163
|
const clients = [];
|
|
164
164
|
const pools = [];
|
|
165
165
|
let mariaDBPool, mariaDBClient, mariaDBCredential, onceCredential = connectOnce ? batch[0].credential : undefined;
|
|
166
166
|
const getConnection = async (item, credential) => {
|
|
167
|
-
item.transactionState = 64
|
|
167
|
+
item.transactionState = 64;
|
|
168
168
|
let client;
|
|
169
169
|
if (mariaDBPool) {
|
|
170
170
|
pools.push(client = await mariaDBPool.getConnection());
|
|
171
|
-
item.transactionState &= ~64
|
|
171
|
+
item.transactionState &= ~64;
|
|
172
172
|
return client;
|
|
173
173
|
}
|
|
174
174
|
const pool = item.usePool && DbPool.findKey(POOL_STATE, item.usePool, getPoolKey(credential), ...connectOnce ? [item, batch[0]] : [item]);
|
|
@@ -211,15 +211,15 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
211
211
|
}
|
|
212
212
|
mariaDBCredential = credential;
|
|
213
213
|
}
|
|
214
|
-
item.transactionState &= ~64
|
|
214
|
+
item.transactionState &= ~64;
|
|
215
215
|
return client;
|
|
216
216
|
};
|
|
217
217
|
for (let i = 0; i < length; ++i) {
|
|
218
218
|
const item = batch[i];
|
|
219
219
|
const { source, query, params, ignoreCache } = item;
|
|
220
220
|
let credential = mariaDBCredential || onceCredential, error;
|
|
221
|
-
const streamRow = typeof item.streamRow === 'string' ? this.hasCoerce("mariadb"
|
|
222
|
-
if (!(0, types_1.isPlainObject)(credential = item.credential) && (error = (0, types_1.errorMessage)(source, "Invalid credentials"
|
|
221
|
+
const streamRow = typeof item.streamRow === 'string' ? this.hasCoerce("mariadb", 'options', null, item.credential) && (0, types_1.asFunction)(item.streamRow) : item.streamRow;
|
|
222
|
+
if (!(0, types_1.isPlainObject)(credential = item.credential) && (error = (0, types_1.errorMessage)(source, "Invalid credentials")) || !query && (error = (0, types_1.errorMessage)(source, "Missing database query"))) {
|
|
223
223
|
if (this.handleFail(error, item, { errorQuery })) {
|
|
224
224
|
if (!parallel) {
|
|
225
225
|
tasks.length = 0;
|
|
@@ -235,7 +235,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
235
235
|
}
|
|
236
236
|
continue;
|
|
237
237
|
}
|
|
238
|
-
item.transactionState = 1
|
|
238
|
+
item.transactionState = 1;
|
|
239
239
|
const renewCache = ignoreCache === 0;
|
|
240
240
|
const cacheValue = renewCache ? { sessionKey, renewCache } : sessionKey;
|
|
241
241
|
let queryString = '';
|
|
@@ -250,7 +250,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
250
250
|
else {
|
|
251
251
|
outResult[i] = result;
|
|
252
252
|
}
|
|
253
|
-
this.add(item, 4
|
|
253
|
+
this.add(item, 4 | 128);
|
|
254
254
|
continue;
|
|
255
255
|
}
|
|
256
256
|
if (!ignoreCache && outCacheMiss) {
|
|
@@ -301,13 +301,13 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
301
301
|
reject(error);
|
|
302
302
|
}
|
|
303
303
|
else {
|
|
304
|
-
this.add(item, 4
|
|
304
|
+
this.add(item, 4);
|
|
305
305
|
resolve(!error ? this.setQueryResult(source, removePoolProperties(credential), queryString, rows, cacheValue) : rows.length ? rows : null);
|
|
306
306
|
}
|
|
307
307
|
}
|
|
308
308
|
else {
|
|
309
309
|
const rows = await client.query(query, params);
|
|
310
|
-
this.add(item, 4
|
|
310
|
+
this.add(item, 4);
|
|
311
311
|
if ((0, types_1.isArray)(rows)) {
|
|
312
312
|
const [row1, row2] = rows;
|
|
313
313
|
if (rows.length === 2 && Array.isArray(row1) && !Array.isArray(row2) && isOkPacket(row2)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/mariadb",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "MariaDB 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/mariadb"
|
|
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.5.
|
|
25
|
-
"@e-mc/types": "^0.5.
|
|
26
|
-
"mariadb": "^3.2.
|
|
24
|
+
"@e-mc/db": "^0.5.4",
|
|
25
|
+
"@e-mc/types": "^0.5.4",
|
|
26
|
+
"mariadb": "^3.2.3"
|
|
27
27
|
}
|
|
28
28
|
}
|