@pi-r/oracle 0.6.0 → 0.6.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/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  ### @pi-r/oracle
2
2
 
3
+ https://e-mc.readthedocs.io/en/latest/db/oracle.html
4
+
3
5
  ### LICENSE
4
6
 
5
7
  MIT
package/client/index.js CHANGED
@@ -56,8 +56,12 @@ function removePoolProperties(credential) {
56
56
  return credential;
57
57
  }
58
58
  function getPoolKey(credential) {
59
- if (credential.connectString && (credential.user && credential.password || credential.externalAuth)) {
60
- return credential.connectString + '_' + (credential.externalAuth ? 'external' : credential.user + '_' + credential.password) + '_' + (credential.edition || '') + '_' + (credential.tag ? credential.tag + '#' + (credential.matchAny ? '1' : '0') : '') + '_' + (credential.privilege ?? '') + '_' + (credential.configDir || '') + '_' + (credential.walletLocation || '') + '_' + (credential.sourceRoute || '') + '_' + Db.asString(credential.shardingKey, true) + '_' + Db.asString(credential.superShardingKey, true);
59
+ if (credential.connectString && (credential.user && credential.password || credential.externalAuth) || credential.poolAlias) {
60
+ if ('uuidKey' in credential) {
61
+ credential = { ...credential };
62
+ delete credential.uuidKey;
63
+ }
64
+ return JSON.stringify(credential);
61
65
  }
62
66
  }
63
67
  const useLibDir = () => process.platform === 'win32' || process.platform === 'darwin' && process.arch === 'x64';
@@ -157,10 +161,16 @@ async function setCredential(item) {
157
161
  }
158
162
  const poolAlias = credential.poolAlias;
159
163
  let password, pool;
160
- if (typeof usePool === 'string' && (username = credential.user || poolAlias)) {
161
- [password, pool] = DbPool.validateKey(POOL_STATE, username, usePool);
162
- if (pool) {
163
- pool.add(item, password);
164
+ if ((0, types_1.isString)(usePool)) {
165
+ if (username = credential.user || poolAlias) {
166
+ [password, pool] = DbPool.validateKey(POOL_STATE, username, usePool);
167
+ if (pool) {
168
+ pool.add(item, password);
169
+ return;
170
+ }
171
+ }
172
+ if (!password) {
173
+ item.usePool = '';
164
174
  return;
165
175
  }
166
176
  }
@@ -177,15 +187,6 @@ async function setCredential(item) {
177
187
  }
178
188
  }
179
189
  }
180
- const poolKey = getPoolKey(credential);
181
- if (!poolKey) {
182
- item.usePool = false;
183
- return;
184
- }
185
- if ((pool = POOL_STATE[poolKey]) && !pool.closed) {
186
- pool.add(item);
187
- return;
188
- }
189
190
  const config = this.getPoolConfig("oracle" /* STRINGS.MODULE_NAME */, password);
190
191
  if (config) {
191
192
  const { min, max, idle, queue_max, queue_idle, timeout } = config;
@@ -208,6 +209,11 @@ async function setCredential(item) {
208
209
  credential.connectTimeout ?? (credential.connectTimeout = idle / 1000);
209
210
  }
210
211
  }
212
+ const poolKey = getPoolKey(credential);
213
+ if ((pool = POOL_STATE[poolKey]) && !pool.closed) {
214
+ pool.add(item);
215
+ return;
216
+ }
211
217
  new OraclePool(await oracledb.createPool(credential), poolKey, username && password ? { username, password } : undefined).add(item).parent = POOL_STATE;
212
218
  }
213
219
  exports.setCredential = setCredential;
@@ -315,10 +321,9 @@ async function executeBatchQuery(batch, options = '', outResult) {
315
321
  }
316
322
  item.transactionState = 1 /* DB_TRANSACTION.ACTIVE */;
317
323
  const streamRow = typeof item.streamRow === 'string' ? this.hasCoerce("oracle" /* STRINGS.MODULE_NAME */, 'options', null, credential) && (0, types_1.asFunction)(item.streamRow) : item.streamRow;
318
- const renewCache = ignoreCache === 0;
319
- const cacheValue = renewCache ? { sessionKey, renewCache } : sessionKey;
324
+ const cacheValue = ignoreCache === undefined ? sessionKey : Array.isArray(ignoreCache) ? { sessionKey, exclusiveOf: ignoreCache } : { sessionKey, renewCache: ignoreCache === 0 };
320
325
  let queryString = '';
321
- if ((caching && ignoreCache !== true || ignoreCache === false || ignoreCache === 1 || renewCache) && !streamRow) {
326
+ if (caching && ignoreCache !== true && !streamRow) {
322
327
  queryString = Db.asString(query, true) + '_' + Db.asString(params, true) + Db.asString(clientOptions, true);
323
328
  if (ignoreCache !== 1) {
324
329
  const result = this.getQueryResult(source, removePoolProperties(credential), queryString, cacheValue);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/oracle",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
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.8.0",
25
- "@e-mc/types": "^0.8.0",
24
+ "@e-mc/db": "^0.8.2",
25
+ "@e-mc/types": "^0.8.2",
26
26
  "oracledb": "^6.3.0"
27
27
  }
28
28
  }
package/types/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import type { DbDataSource } from '@e-mc/types/lib/squared';
2
2
 
3
3
  import type { ExecuteAction, ServerAuth } from '@e-mc/types/lib/db';
4
4
 
5
- import type { BindParameters, ConnectionAttributes, ExecuteOptions, PoolAttributes, InitialiseOptions } from 'oracledb';
5
+ import type { BindParameters, ConnectionAttributes, ExecuteOptions, InitialiseOptions, PoolAttributes } from 'oracledb';
6
6
 
7
7
  export interface OracleDataSource extends DbDataSource<string, ExecuteOptions, unknown, string | OracleCredential, string>, ExecuteAction<BindParameters> {
8
8
  source: "oracle";