@pi-r/oracle 0.12.5 → 0.13.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 +51 -19
- package/package.json +2 -2
- package/types/index.d.ts +3 -2
package/client/index.js
CHANGED
|
@@ -268,26 +268,33 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
268
268
|
continue;
|
|
269
269
|
}
|
|
270
270
|
item.transactionState = 1;
|
|
271
|
-
const streamRow = typeof item.streamRow === 'string' ? this.hasCoerce("oracle", 'options', credential) && asFunction(item.streamRow) : item.streamRow;
|
|
272
271
|
const cacheValue = ignoreCache === undefined ? sessionKey : Array.isArray(ignoreCache) ? { sessionKey, exclusiveOf: ignoreCache } : { sessionKey, renewCache: ignoreCache === 0 };
|
|
273
|
-
let queryString = '', cacheCredential;
|
|
274
|
-
if (
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
272
|
+
let queryString = '', pipeline, streamRow, cacheCredential;
|
|
273
|
+
if (query instanceof oracledb.Pipeline) {
|
|
274
|
+
pipeline = query;
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
if (isString(query)) {
|
|
278
|
+
streamRow = typeof item.streamRow === 'string' ? this.hasCoerce("oracle", 'options', credential) && asFunction(item.streamRow) : item.streamRow;
|
|
279
|
+
}
|
|
280
|
+
if (caching && ignoreCache !== true && !streamRow) {
|
|
281
|
+
queryString = Db.keyForResult(query, params, clientOptions);
|
|
282
|
+
cacheCredential = DbPool.sanitize(credential, sortKeys);
|
|
283
|
+
if (ignoreCache !== 1) {
|
|
284
|
+
const result = this.getQueryResult(source, cacheCredential, queryString, cacheValue);
|
|
285
|
+
if (result) {
|
|
286
|
+
if (parallel) {
|
|
287
|
+
tasks[i] = Promise.resolve(result);
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
outResult[i] = result;
|
|
291
|
+
}
|
|
292
|
+
this.add(item, 4 | 128);
|
|
293
|
+
continue;
|
|
282
294
|
}
|
|
283
|
-
|
|
284
|
-
|
|
295
|
+
if (!ignoreCache && outCacheMiss) {
|
|
296
|
+
outCacheMiss.push(source);
|
|
285
297
|
}
|
|
286
|
-
this.add(item, 4 | 128);
|
|
287
|
-
continue;
|
|
288
|
-
}
|
|
289
|
-
if (!ignoreCache && outCacheMiss) {
|
|
290
|
-
outCacheMiss.push(source);
|
|
291
298
|
}
|
|
292
299
|
}
|
|
293
300
|
}
|
|
@@ -310,7 +317,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
310
317
|
}
|
|
311
318
|
const executeOptions = { outFormat: oracledb.OUT_FORMAT_OBJECT, ...clientOptions, resultSet: false, autoCommit: true };
|
|
312
319
|
commandType = this.commandType.SELECT;
|
|
313
|
-
if (streamRow
|
|
320
|
+
if (streamRow) {
|
|
314
321
|
const rows = [];
|
|
315
322
|
const processRow = typeof streamRow === 'function' ? streamRow : null;
|
|
316
323
|
const stream = client.queryStream(query, params || [], executeOptions);
|
|
@@ -341,7 +348,32 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
341
348
|
.on('end', () => stream.destroy());
|
|
342
349
|
}
|
|
343
350
|
else {
|
|
344
|
-
|
|
351
|
+
let rows;
|
|
352
|
+
if (pipeline) {
|
|
353
|
+
let result = await client.runPipeline(pipeline);
|
|
354
|
+
if (item.pipelineRows) {
|
|
355
|
+
result = result.filter(oper => oper.rows);
|
|
356
|
+
if (result.length > 0) {
|
|
357
|
+
switch (item.pipelineRows) {
|
|
358
|
+
case 'first':
|
|
359
|
+
rows = result[0].rows;
|
|
360
|
+
break;
|
|
361
|
+
case 'last':
|
|
362
|
+
rows = result.at(-1).rows;
|
|
363
|
+
break;
|
|
364
|
+
default:
|
|
365
|
+
rows = result.map(oper => oper.rows);
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
rows = result;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
({ rows } = await client.execute(query, params || [], executeOptions));
|
|
376
|
+
}
|
|
345
377
|
this.add(item, 4);
|
|
346
378
|
resolve(rows ? this.setQueryResult(source, cacheCredential, queryString, rows, cacheValue) : null);
|
|
347
379
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/oracle",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Oracle client driver for E-mc.",
|
|
5
5
|
"main": "client/index.js",
|
|
6
6
|
"types": "client/index.d.ts",
|
|
@@ -19,6 +19,6 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@e-mc/db": "^0.14.6",
|
|
21
21
|
"@e-mc/types": "^0.14.6",
|
|
22
|
-
"oracledb": "^
|
|
22
|
+
"oracledb": "^7.0.1"
|
|
23
23
|
}
|
|
24
24
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { IdentifierAction } from '@e-mc/types/lib/core';
|
|
|
4
4
|
import type { ExecuteAction, ServerAuth } from '@e-mc/types/lib/db';
|
|
5
5
|
|
|
6
6
|
// @ts-ignore
|
|
7
|
-
import type { BindParameters, ConnectionAttributes, ExecuteOptions, InitialiseOptions, PoolAttributes } from 'oracledb';
|
|
7
|
+
import type { BindParameters, ConnectionAttributes, ExecuteOptions, InitialiseOptions, Pipeline, PoolAttributes } from 'oracledb';
|
|
8
8
|
|
|
9
9
|
export const enum POOL_STATUS {
|
|
10
10
|
CLOSED = 6002,
|
|
@@ -13,8 +13,9 @@ export const enum POOL_STATUS {
|
|
|
13
13
|
RECONFIGURING = 6003
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export interface OracleDataSource extends DbDataSource<string | object, ExecuteOptions, unknown, OracleCredential, string>, ExecuteAction<BindParameters> {
|
|
16
|
+
export interface OracleDataSource extends DbDataSource<string | object | Pipeline, ExecuteOptions, unknown, OracleCredential, string>, ExecuteAction<BindParameters> {
|
|
17
17
|
source: "oracle";
|
|
18
|
+
pipelineRows?: boolean | "first" | "last";
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export type OracleCredential = ConnectionAttributes & PoolAttributes & InitialiseOptions & ServerAuth;
|