@pi-r/mariadb 0.6.4 → 0.6.5
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 +6 -3
- package/client/index.d.ts +7 -0
- package/client/index.js +12 -12
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright
|
|
1
|
+
Copyright 2024 An Pham
|
|
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
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
# @pi-r/mariadb
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Documentation
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
- [E-mc](https://e-mc.readthedocs.io/en/latest/db/mariadb.html)
|
|
6
|
+
- [squared](https://squared.readthedocs.io)
|
|
7
|
+
|
|
8
|
+
## LICENSE
|
|
6
9
|
|
|
7
10
|
MIT
|
package/client/index.js
CHANGED
|
@@ -101,7 +101,7 @@ function setCredential(item) {
|
|
|
101
101
|
errors.push('user');
|
|
102
102
|
}
|
|
103
103
|
if (errors.length) {
|
|
104
|
-
throw (0, types_1.errorMessage)("mariadb"
|
|
104
|
+
throw (0, types_1.errorMessage)("mariadb", 'Not defined - ' + errors.join(' | '));
|
|
105
105
|
}
|
|
106
106
|
const usePool = item.usePool;
|
|
107
107
|
if (!usePool) {
|
|
@@ -121,7 +121,7 @@ function setCredential(item) {
|
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
const config = this.getPoolConfig("mariadb"
|
|
124
|
+
const config = this.getPoolConfig("mariadb", password);
|
|
125
125
|
if (config) {
|
|
126
126
|
const { min, max, idle, queue_idle, timeout, socket_timeout } = config;
|
|
127
127
|
if (min >= 0) {
|
|
@@ -180,17 +180,17 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
180
180
|
if (!parallel) {
|
|
181
181
|
outResult || (outResult = new Array(length));
|
|
182
182
|
}
|
|
183
|
-
const caching = this.hasCache("mariadb"
|
|
183
|
+
const caching = this.hasCache("mariadb", sessionKey);
|
|
184
184
|
const tasks = new Array(length);
|
|
185
185
|
const clients = [];
|
|
186
186
|
const pools = [];
|
|
187
187
|
let mariaDBPool, mariaDBClient, mariaDBCredential, onceCredential = connectOnce ? batch[0].credential : undefined;
|
|
188
188
|
const getConnection = async (item, credential) => {
|
|
189
|
-
item.transactionState = 64
|
|
189
|
+
item.transactionState = 64;
|
|
190
190
|
let client;
|
|
191
191
|
if (mariaDBPool) {
|
|
192
192
|
pools.push(client = await mariaDBPool.getConnection());
|
|
193
|
-
item.transactionState &= ~64
|
|
193
|
+
item.transactionState &= ~64;
|
|
194
194
|
POOL_ACTIVE.add(credential);
|
|
195
195
|
return client;
|
|
196
196
|
}
|
|
@@ -235,7 +235,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
235
235
|
}
|
|
236
236
|
mariaDBCredential = credential;
|
|
237
237
|
}
|
|
238
|
-
item.transactionState &= ~64
|
|
238
|
+
item.transactionState &= ~64;
|
|
239
239
|
return client;
|
|
240
240
|
};
|
|
241
241
|
if (this.host?.username) {
|
|
@@ -245,8 +245,8 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
245
245
|
const item = batch[i];
|
|
246
246
|
const { source, query, params, ignoreCache } = item;
|
|
247
247
|
let credential = mariaDBCredential || onceCredential, error;
|
|
248
|
-
const streamRow = typeof item.streamRow === 'string' ? this.hasCoerce("mariadb"
|
|
249
|
-
if (!(0, types_1.isPlainObject)(credential = item.credential) && (error = (0, types_1.errorMessage)(source, "Invalid credentials"
|
|
248
|
+
const streamRow = typeof item.streamRow === 'string' ? this.hasCoerce("mariadb", 'options', null, item.credential) && (0, types_1.asFunction)(item.streamRow) : item.streamRow;
|
|
249
|
+
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"))) {
|
|
250
250
|
if (this.handleFail(error, item, { errorQuery })) {
|
|
251
251
|
if (!parallel) {
|
|
252
252
|
tasks.length = 0;
|
|
@@ -262,7 +262,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
262
262
|
}
|
|
263
263
|
continue;
|
|
264
264
|
}
|
|
265
|
-
item.transactionState = 1
|
|
265
|
+
item.transactionState = 1;
|
|
266
266
|
const cacheValue = ignoreCache === undefined ? sessionKey : Array.isArray(ignoreCache) ? { sessionKey, exclusiveOf: ignoreCache } : { sessionKey, renewCache: ignoreCache === 0 };
|
|
267
267
|
let queryString = '';
|
|
268
268
|
if (caching && ignoreCache !== true && !streamRow) {
|
|
@@ -276,7 +276,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
276
276
|
else {
|
|
277
277
|
outResult[i] = result;
|
|
278
278
|
}
|
|
279
|
-
this.add(item, 4
|
|
279
|
+
this.add(item, 4 | 128);
|
|
280
280
|
continue;
|
|
281
281
|
}
|
|
282
282
|
if (!ignoreCache && outCacheMiss) {
|
|
@@ -327,13 +327,13 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
327
327
|
reject(error);
|
|
328
328
|
}
|
|
329
329
|
else {
|
|
330
|
-
this.add(item, 4
|
|
330
|
+
this.add(item, 4);
|
|
331
331
|
resolve(!error ? this.setQueryResult(source, removePoolProperties(credential), queryString, rows, cacheValue) : rows.length ? rows : null);
|
|
332
332
|
}
|
|
333
333
|
}
|
|
334
334
|
else {
|
|
335
335
|
const rows = await client.query(query, params);
|
|
336
|
-
this.add(item, 4
|
|
336
|
+
this.add(item, 4);
|
|
337
337
|
if ((0, types_1.isArray)(rows)) {
|
|
338
338
|
const [row1, row2] = rows;
|
|
339
339
|
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.6.
|
|
3
|
+
"version": "0.6.5",
|
|
4
4
|
"description": "MariaDB 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.
|
|
24
|
+
"@e-mc/db": "^0.8.6",
|
|
25
|
+
"@e-mc/types": "^0.8.6",
|
|
26
26
|
"mariadb": "^3.2.3"
|
|
27
27
|
}
|
|
28
28
|
}
|