@pi-r/oracle 0.3.0 → 0.4.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/client/index.js +19 -9
- package/package.json +4 -4
package/client/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DB_SOURCE_TYPE = exports.DB_SOURCE_CLIENT = exports.checkTimeout = exports.executeBatchQuery = exports.executeQuery = exports.setCredential = void 0;
|
|
4
|
+
const oracledb = require("oracledb");
|
|
4
5
|
const util_1 = require("@e-mc/db/util");
|
|
5
6
|
const types_1 = require("@e-mc/types");
|
|
6
7
|
const Db = require("@e-mc/db");
|
|
@@ -24,11 +25,22 @@ class OraclePool extends DbPool {
|
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
const POOL_STATE = {};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const POOL_UNUSED = ['poolMax', 'poolMin', 'poolIncrement', 'poolTimeout', 'poolPingInterval', 'poolMaxPerShard', 'queueMax', 'queueRequests', 'queueTimeout'];
|
|
29
|
+
function removePoolProperties(credential) {
|
|
30
|
+
if (!credential.uuidKey) {
|
|
31
|
+
let result;
|
|
32
|
+
for (let i = 0, length = POOL_UNUSED.length; i < length; ++i) {
|
|
33
|
+
const attr = POOL_UNUSED[i];
|
|
34
|
+
if (attr in credential) {
|
|
35
|
+
result || (result = { ...credential });
|
|
36
|
+
delete result[attr];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (result) {
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
30
42
|
}
|
|
31
|
-
return
|
|
43
|
+
return credential;
|
|
32
44
|
}
|
|
33
45
|
function getPoolKey(credential) {
|
|
34
46
|
if (credential.connectString && (credential.user && credential.password || credential.externalAuth)) {
|
|
@@ -114,7 +126,6 @@ async function setCredential(item) {
|
|
|
114
126
|
const poolKey = getPoolKey(credential);
|
|
115
127
|
if (poolKey) {
|
|
116
128
|
if (!(pool = POOL_STATE[poolKey]) || pool.closed) {
|
|
117
|
-
const { createPool } = require("oracledb" /* STRINGS.PACKAGE_NAME */);
|
|
118
129
|
const config = this.getPoolConfig("oracle" /* STRINGS.MODULE_NAME */, password);
|
|
119
130
|
if (config) {
|
|
120
131
|
const { min, max, idle, queue_max, queue_idle } = config;
|
|
@@ -134,7 +145,7 @@ async function setCredential(item) {
|
|
|
134
145
|
credential.queueTimeout ?? (credential.queueTimeout = queue_idle);
|
|
135
146
|
}
|
|
136
147
|
}
|
|
137
|
-
new OraclePool(await createPool(credential), poolKey, username && password ? { username, password } : undefined).add(item).parent = POOL_STATE;
|
|
148
|
+
new OraclePool(await oracledb.createPool(credential), poolKey, username && password ? { username, password } : undefined).add(item).parent = POOL_STATE;
|
|
138
149
|
}
|
|
139
150
|
else {
|
|
140
151
|
pool.add(item);
|
|
@@ -155,7 +166,6 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
155
166
|
if (length === 0) {
|
|
156
167
|
return [];
|
|
157
168
|
}
|
|
158
|
-
const db = require("oracledb" /* STRINGS.PACKAGE_NAME */);
|
|
159
169
|
let parallel, connectOnce, errorQuery, sessionKey, outCacheMiss;
|
|
160
170
|
if ((0, types_1.isPlainObject)(options)) {
|
|
161
171
|
({ parallel, connectOnce, errorQuery, sessionKey } = options);
|
|
@@ -216,7 +226,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
216
226
|
pool.connected = false;
|
|
217
227
|
}
|
|
218
228
|
}
|
|
219
|
-
clients.push(client || (client = await
|
|
229
|
+
clients.push(client || (client = await oracledb.getConnection((oracleCredential || credential))));
|
|
220
230
|
if (connectOnce) {
|
|
221
231
|
if (!parallel) {
|
|
222
232
|
oracleClient = client;
|
|
@@ -287,7 +297,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
287
297
|
if (oracleClient && parallel) {
|
|
288
298
|
oracleClient = undefined;
|
|
289
299
|
}
|
|
290
|
-
const executeOptions = { outFormat:
|
|
300
|
+
const executeOptions = { outFormat: oracledb.OUT_FORMAT_OBJECT, ...clientOptions, resultSet: false, autoCommit: true };
|
|
291
301
|
commandType = this.commandType.SELECT;
|
|
292
302
|
if (streamRow) {
|
|
293
303
|
const rows = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/oracle",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.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.0.
|
|
24
|
+
"@e-mc/db": "^0.6.0",
|
|
25
|
+
"@e-mc/types": "^0.6.0",
|
|
26
|
+
"oracledb": "^6.0.3"
|
|
27
27
|
}
|
|
28
28
|
}
|