@pi-r/oracle 0.5.0 → 0.5.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/LICENSE +1 -1
- package/README.md +4 -2
- package/client/index.d.ts +2 -2
- package/client/index.js +15 -15
- package/package.json +5 -5
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright 2023
|
|
1
|
+
Copyright 2023 Wit Studio
|
|
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.d.ts
CHANGED
package/client/index.js
CHANGED
|
@@ -18,10 +18,10 @@ class OraclePool extends DbPool {
|
|
|
18
18
|
return this.closed || connectionsInUse === 0 && currentQueueLength === 0;
|
|
19
19
|
}
|
|
20
20
|
get closeable() {
|
|
21
|
-
return super.closeable || this.client.status === 6001
|
|
21
|
+
return super.closeable || this.client.status === 6001;
|
|
22
22
|
}
|
|
23
23
|
get closed() {
|
|
24
|
-
return this.client.status === 6002
|
|
24
|
+
return this.client.status === 6002;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
const POOL_STATE = {};
|
|
@@ -96,7 +96,7 @@ async function setCredential(item) {
|
|
|
96
96
|
errors.push('connectString');
|
|
97
97
|
}
|
|
98
98
|
if (errors.length) {
|
|
99
|
-
throw (0, types_1.errorMessage)("oracle"
|
|
99
|
+
throw (0, types_1.errorMessage)("oracle", 'Not defined - ' + errors.join(' | '));
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
const usePool = item.usePool;
|
|
@@ -126,7 +126,7 @@ async function setCredential(item) {
|
|
|
126
126
|
const poolKey = getPoolKey(credential);
|
|
127
127
|
if (poolKey) {
|
|
128
128
|
if (!(pool = POOL_STATE[poolKey]) || pool.closed) {
|
|
129
|
-
const config = this.getPoolConfig("oracle"
|
|
129
|
+
const config = this.getPoolConfig("oracle", password);
|
|
130
130
|
if (config) {
|
|
131
131
|
const { min, max, idle, queue_max, queue_idle, timeout } = config;
|
|
132
132
|
if (min >= 0) {
|
|
@@ -189,16 +189,16 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
189
189
|
if (!parallel) {
|
|
190
190
|
outResult || (outResult = new Array(length));
|
|
191
191
|
}
|
|
192
|
-
const caching = this.hasCache("oracle"
|
|
192
|
+
const caching = this.hasCache("oracle", sessionKey);
|
|
193
193
|
const tasks = new Array(length);
|
|
194
194
|
const clients = [];
|
|
195
195
|
let oraclePool, oracleClient, oracleCredential, onceCredential = connectOnce ? batch[0].credential : undefined;
|
|
196
196
|
const getConnection = async (item, credential) => {
|
|
197
|
-
item.transactionState = 64
|
|
197
|
+
item.transactionState = 64;
|
|
198
198
|
let client;
|
|
199
199
|
if (oraclePool) {
|
|
200
200
|
clients.push(client = await oraclePool.getConnection());
|
|
201
|
-
item.transactionState &= ~64
|
|
201
|
+
item.transactionState &= ~64;
|
|
202
202
|
return client;
|
|
203
203
|
}
|
|
204
204
|
const pool = item.usePool && DbPool.findKey(POOL_STATE, item.usePool, getPoolKey(credential), ...connectOnce ? [item, batch[0]] : [item]);
|
|
@@ -236,14 +236,14 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
236
236
|
}
|
|
237
237
|
oracleCredential = credential;
|
|
238
238
|
}
|
|
239
|
-
item.transactionState &= ~64
|
|
239
|
+
item.transactionState &= ~64;
|
|
240
240
|
return client;
|
|
241
241
|
};
|
|
242
242
|
for (let i = 0; i < length; ++i) {
|
|
243
243
|
const item = batch[i];
|
|
244
244
|
const { source, query, params, ignoreCache, options: clientOptions } = item;
|
|
245
245
|
let credential = oracleCredential || onceCredential, error;
|
|
246
|
-
if (!credential && !(0, types_1.isPlainObject)(credential = item.credential) && (error = (0, types_1.errorMessage)(source, "Invalid credentials"
|
|
246
|
+
if (!credential && !(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"))) {
|
|
247
247
|
if (this.handleFail(error, item, { errorQuery })) {
|
|
248
248
|
if (!parallel) {
|
|
249
249
|
tasks.length = 0;
|
|
@@ -259,8 +259,8 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
259
259
|
}
|
|
260
260
|
continue;
|
|
261
261
|
}
|
|
262
|
-
item.transactionState = 1
|
|
263
|
-
const streamRow = typeof item.streamRow === 'string' ? this.hasCoerce("oracle"
|
|
262
|
+
item.transactionState = 1;
|
|
263
|
+
const streamRow = typeof item.streamRow === 'string' ? this.hasCoerce("oracle", 'options', null, credential) && (0, types_1.asFunction)(item.streamRow) : item.streamRow;
|
|
264
264
|
const renewCache = ignoreCache === 0;
|
|
265
265
|
const cacheValue = renewCache ? { sessionKey, renewCache } : sessionKey;
|
|
266
266
|
let queryString = '';
|
|
@@ -275,7 +275,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
275
275
|
else {
|
|
276
276
|
outResult[i] = result;
|
|
277
277
|
}
|
|
278
|
-
this.add(item, 4
|
|
278
|
+
this.add(item, 4 | 128);
|
|
279
279
|
continue;
|
|
280
280
|
}
|
|
281
281
|
if (!ignoreCache && outCacheMiss) {
|
|
@@ -326,7 +326,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
326
326
|
reject(error);
|
|
327
327
|
}
|
|
328
328
|
else {
|
|
329
|
-
this.add(item, 4
|
|
329
|
+
this.add(item, 4);
|
|
330
330
|
resolve(!error ? this.setQueryResult(source, removePoolProperties(credential), queryString, rows, cacheValue) : rows);
|
|
331
331
|
}
|
|
332
332
|
})
|
|
@@ -334,7 +334,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
334
334
|
}
|
|
335
335
|
else {
|
|
336
336
|
const { rows } = await client.execute(query, params || [], executeOptions);
|
|
337
|
-
this.add(item, 4
|
|
337
|
+
this.add(item, 4);
|
|
338
338
|
resolve(rows ? this.setQueryResult(source, removePoolProperties(credential), queryString, rows, cacheValue) : null);
|
|
339
339
|
}
|
|
340
340
|
}
|
|
@@ -358,7 +358,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
return this.processRows(batch, tasks, {
|
|
361
|
-
disconnect: () => clients.forEach(item => item.close(err => err && this.writeFail(["Unable to close connnection"
|
|
361
|
+
disconnect: () => clients.forEach(item => item.close(err => err && this.writeFail(["Unable to close connnection", "oracle"], err, { type: 65536, fatal: false }))),
|
|
362
362
|
parallel
|
|
363
363
|
}, outResult);
|
|
364
364
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/oracle",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Oracle 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/oracle"
|
|
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.7.
|
|
25
|
-
"@e-mc/types": "^0.7.
|
|
26
|
-
"oracledb": "^6.
|
|
24
|
+
"@e-mc/db": "^0.7.2",
|
|
25
|
+
"@e-mc/types": "^0.7.2",
|
|
26
|
+
"oracledb": "^6.3.0"
|
|
27
27
|
}
|
|
28
28
|
}
|