@pi-r/oracle 0.6.5 → 0.7.0
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/README.md +3 -6
- package/client/index.d.ts +0 -1
- package/client/index.js +22 -21
- package/package.json +4 -4
- package/types/index.d.ts +1 -1
package/README.md
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
### @pi-r/oracle
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
https://e-mc.readthedocs.io/en/latest/db/oracle.html
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
- [squared](https://squared.readthedocs.io)
|
|
7
|
-
|
|
8
|
-
## LICENSE
|
|
5
|
+
### LICENSE
|
|
9
6
|
|
|
10
7
|
MIT
|
package/client/index.d.ts
CHANGED
package/client/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
2
|
exports.DB_SOURCE_TYPE = exports.DB_SOURCE_CLIENT = exports.checkTimeout = exports.executeBatchQuery = exports.executeQuery = exports.setCredential = exports.initOracleClient = void 0;
|
|
4
3
|
const oracledb = require("oracledb");
|
|
5
4
|
const util_1 = require("@e-mc/db/util");
|
|
@@ -46,7 +45,7 @@ function removePoolProperties(credential) {
|
|
|
46
45
|
for (let i = 0, length = POOL_UNUSED.length; i < length; ++i) {
|
|
47
46
|
const attr = POOL_UNUSED[i];
|
|
48
47
|
if (attr in credential) {
|
|
49
|
-
result
|
|
48
|
+
result ||= { ...credential };
|
|
50
49
|
delete result[attr];
|
|
51
50
|
}
|
|
52
51
|
}
|
|
@@ -106,14 +105,10 @@ exports.initOracleClient = initOracleClient;
|
|
|
106
105
|
async function setCredential(item) {
|
|
107
106
|
let credential = this.getCredential(item), hostname, port, username, database;
|
|
108
107
|
if (credential) {
|
|
109
|
-
({ hostname, port, username } = (0, util_1.parseServerAuth)(credential));
|
|
110
|
-
credential.user
|
|
111
|
-
if ('database' in credential) {
|
|
112
|
-
database = credential.database;
|
|
113
|
-
delete credential.database;
|
|
114
|
-
}
|
|
108
|
+
({ hostname, port, database, username } = (0, util_1.parseServerAuth)(credential));
|
|
109
|
+
credential.user ||= username;
|
|
115
110
|
if ('connectionString' in credential) {
|
|
116
|
-
credential.connectString
|
|
111
|
+
credential.connectString ||= credential.connectionString;
|
|
117
112
|
delete credential.connectionString;
|
|
118
113
|
}
|
|
119
114
|
}
|
|
@@ -132,7 +127,7 @@ async function setCredential(item) {
|
|
|
132
127
|
item.credential = credential;
|
|
133
128
|
}
|
|
134
129
|
if (hostname) {
|
|
135
|
-
credential.connectString
|
|
130
|
+
credential.connectString ||= hostname + (port ? ':' + port : '') + (database ? '/' + database : '');
|
|
136
131
|
}
|
|
137
132
|
if (credential.externalAuth) {
|
|
138
133
|
delete credential.user;
|
|
@@ -192,22 +187,22 @@ async function setCredential(item) {
|
|
|
192
187
|
if (config) {
|
|
193
188
|
const { min, max, idle, queue_max, queue_idle, timeout } = config;
|
|
194
189
|
if (min >= 0) {
|
|
195
|
-
credential.poolMin
|
|
190
|
+
credential.poolMin ??= min;
|
|
196
191
|
}
|
|
197
192
|
if (max > 0) {
|
|
198
|
-
credential.poolMax
|
|
193
|
+
credential.poolMax ??= max;
|
|
199
194
|
}
|
|
200
195
|
if (idle >= 0) {
|
|
201
|
-
credential.poolTimeout
|
|
196
|
+
credential.poolTimeout ??= idle / 1000;
|
|
202
197
|
}
|
|
203
198
|
if (queue_max >= 0) {
|
|
204
|
-
credential.queueMax
|
|
199
|
+
credential.queueMax ??= queue_max;
|
|
205
200
|
}
|
|
206
201
|
if (queue_idle >= 0) {
|
|
207
|
-
credential.queueTimeout
|
|
202
|
+
credential.queueTimeout ??= queue_idle;
|
|
208
203
|
}
|
|
209
204
|
if (timeout >= 0) {
|
|
210
|
-
credential.connectTimeout
|
|
205
|
+
credential.connectTimeout ??= idle / 1000;
|
|
211
206
|
}
|
|
212
207
|
}
|
|
213
208
|
const poolKey = getPoolKey(credential);
|
|
@@ -245,7 +240,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
245
240
|
parallel = !batch.some(item => item.parallel === false);
|
|
246
241
|
}
|
|
247
242
|
if (!parallel) {
|
|
248
|
-
outResult
|
|
243
|
+
outResult ||= new Array(length);
|
|
249
244
|
}
|
|
250
245
|
const caching = this.hasCache("oracle", sessionKey);
|
|
251
246
|
const tasks = new Array(length);
|
|
@@ -289,7 +284,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
289
284
|
pool.connected = false;
|
|
290
285
|
}
|
|
291
286
|
}
|
|
292
|
-
clients.push(client
|
|
287
|
+
clients.push(client ||= await oracledb.getConnection((oracleCredential || credential)));
|
|
293
288
|
if (connectOnce) {
|
|
294
289
|
if (!parallel) {
|
|
295
290
|
oracleClient = client;
|
|
@@ -323,7 +318,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
323
318
|
continue;
|
|
324
319
|
}
|
|
325
320
|
item.transactionState = 1;
|
|
326
|
-
const streamRow = typeof item.streamRow === 'string' ? this.hasCoerce("oracle", 'options',
|
|
321
|
+
const streamRow = typeof item.streamRow === 'string' ? this.hasCoerce("oracle", 'options', credential) && (0, types_1.asFunction)(item.streamRow) : item.streamRow;
|
|
327
322
|
const cacheValue = ignoreCache === undefined ? sessionKey : Array.isArray(ignoreCache) ? { sessionKey, exclusiveOf: ignoreCache } : { sessionKey, renewCache: ignoreCache === 0 };
|
|
328
323
|
let queryString = '';
|
|
329
324
|
if (caching && ignoreCache !== true && !streamRow) {
|
|
@@ -382,7 +377,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
382
377
|
}
|
|
383
378
|
rows.push(row);
|
|
384
379
|
})
|
|
385
|
-
.on('error', err => error
|
|
380
|
+
.on('error', err => error ||= err)
|
|
386
381
|
.on('close', () => {
|
|
387
382
|
if (error && this.handleFail(error, item, { errorQuery, commandType })) {
|
|
388
383
|
reject(error);
|
|
@@ -420,7 +415,13 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
420
415
|
}
|
|
421
416
|
}
|
|
422
417
|
return this.processRows(batch, tasks, {
|
|
423
|
-
disconnect: () => clients.forEach(item =>
|
|
418
|
+
disconnect: () => clients.forEach(item => {
|
|
419
|
+
item.close(err => {
|
|
420
|
+
if (err) {
|
|
421
|
+
this.writeFail(["Unable to close connnection", "oracle"], err, { type: 65536, fatal: false });
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
}),
|
|
424
425
|
parallel
|
|
425
426
|
}, outResult);
|
|
426
427
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/oracle",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Oracle 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.
|
|
25
|
-
"@e-mc/types": "^0.
|
|
26
|
-
"oracledb": "^6.
|
|
24
|
+
"@e-mc/db": "^0.9.0",
|
|
25
|
+
"@e-mc/types": "^0.9.0",
|
|
26
|
+
"oracledb": "^6.4.0"
|
|
27
27
|
}
|
|
28
28
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { ExecuteAction, ServerAuth } from '@e-mc/types/lib/db';
|
|
|
5
5
|
// @ts-ignore
|
|
6
6
|
import type { BindParameters, ConnectionAttributes, ExecuteOptions, InitialiseOptions, PoolAttributes } from 'oracledb';
|
|
7
7
|
|
|
8
|
-
export interface OracleDataSource extends DbDataSource<string, ExecuteOptions, unknown,
|
|
8
|
+
export interface OracleDataSource extends DbDataSource<string, ExecuteOptions, unknown, OracleCredential, string>, ExecuteAction<BindParameters> {
|
|
9
9
|
source: "oracle";
|
|
10
10
|
}
|
|
11
11
|
|