@pi-r/postgres 0.12.0 → 0.12.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/client/index.js CHANGED
@@ -159,6 +159,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
159
159
  outResult ||= new Array(length);
160
160
  }
161
161
  const caching = this.hasCache("postgres", sessionKey);
162
+ const sortKeys = this.settingsOf("postgres", 'cache', 'sort_keys') === true;
162
163
  const tasks = new Array(length);
163
164
  const clients = [];
164
165
  const pools = [];
@@ -233,11 +234,12 @@ async function executeBatchQuery(batch, options = '', outResult) {
233
234
  item.transactionState = 1;
234
235
  const streamRow = typeof item.streamRow === 'string' ? this.hasCoerce("postgres", 'options', credential) && asFunction(item.streamRow) : item.streamRow;
235
236
  const cacheValue = ignoreCache === undefined ? sessionKey : Array.isArray(ignoreCache) ? { sessionKey, exclusiveOf: ignoreCache } : { sessionKey, renewCache: ignoreCache === 0 };
236
- let queryString = '';
237
+ let queryString = '', cacheCredential;
237
238
  if (caching && ignoreCache !== true) {
238
239
  queryString = Db.asString(query, true) + '_' + Db.asString(params, true) + (streamRow && item.options && isString(query) ? Db.asString(item.options, true) : '');
240
+ cacheCredential = DbPool.sanitize(credential, sortKeys);
239
241
  if (ignoreCache !== 1) {
240
- const result = this.getQueryResult(source, DbPool.sanitize(credential), queryString, cacheValue);
242
+ const result = this.getQueryResult(source, cacheCredential, queryString, cacheValue);
241
243
  if (result) {
242
244
  if (parallel) {
243
245
  tasks[i] = Promise.resolve(result);
@@ -296,7 +298,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
296
298
  }
297
299
  else {
298
300
  this.add(item, 4);
299
- resolve(!error ? this.setQueryResult(source, DbPool.sanitize(credential), queryString, rows, cacheValue) : rows);
301
+ resolve(!error ? this.setQueryResult(source, cacheCredential, queryString, rows, cacheValue) : rows);
300
302
  }
301
303
  })
302
304
  .on('end', () => stream.destroy());
@@ -304,7 +306,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
304
306
  else {
305
307
  const { rows, command } = await client.query(query, params);
306
308
  this.add(item, 4);
307
- resolve(rows.length || command === 'SELECT' ? this.setQueryResult(source, DbPool.sanitize(credential), queryString, rows, cacheValue) : null);
309
+ resolve(rows.length > 0 || command === 'SELECT' ? this.setQueryResult(source, cacheCredential, queryString, rows, cacheValue) : null);
308
310
  }
309
311
  }
310
312
  catch (err) {
package/client/pool.js CHANGED
@@ -11,12 +11,12 @@ class PostgresPool extends DbPool {
11
11
  }
12
12
  return super.asString(credential);
13
13
  }
14
- static sanitize(credential) {
14
+ static sanitize(credential, sort) {
15
15
  if (!POOL_ACTIVE.has(credential) || credential.uuidKey) {
16
16
  return credential;
17
17
  }
18
18
  const ssl = credential.ssl;
19
- let result = super.sanitize(credential);
19
+ let result = super.sanitize(credential, sort);
20
20
  if (isObject(ssl)) {
21
21
  if (result === credential) {
22
22
  result = { ...credential };
package/package.json CHANGED
@@ -1,12 +1,9 @@
1
1
  {
2
2
  "name": "@pi-r/postgres",
3
- "version": "0.12.0",
3
+ "version": "0.12.2",
4
4
  "description": "PostgreSQL client driver for E-mc.",
5
5
  "main": "client/index.js",
6
6
  "types": "client/index.d.ts",
7
- "publishConfig": {
8
- "access": "public"
9
- },
10
7
  "repository": {
11
8
  "type": "git",
12
9
  "url": "git+https://github.com/anpham6/pi-r.git",
@@ -20,13 +17,10 @@
20
17
  "license": "MIT",
21
18
  "homepage": "https://github.com/anpham6/pi-r#readme",
22
19
  "dependencies": {
23
- "@e-mc/db": "^0.14.0",
24
- "@e-mc/types": "^0.14.0",
25
- "pg": "^8.20.0",
26
- "pg-connection-string": "^2.12.0",
27
- "pg-query-stream": "^4.14.0"
28
- },
29
- "peerDependencies": {
30
- "@types/pg": "^8"
20
+ "@e-mc/db": "^0.14.3",
21
+ "@e-mc/types": "^0.14.3",
22
+ "pg": "^8.21.0",
23
+ "pg-connection-string": "^2.13.0",
24
+ "pg-query-stream": "^4.15.0"
31
25
  }
32
26
  }