pg-promise 10.10.2 → 10.12.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 CHANGED
@@ -3,9 +3,6 @@ pg-promise
3
3
 
4
4
  PostgreSQL interface for Node.js
5
5
 
6
- [![Build Status](https://travis-ci.org/vitaly-t/pg-promise.svg?branch=master)](https://travis-ci.org/vitaly-t/pg-promise)
7
- [![Join the chat at https://gitter.im/vitaly-t/pg-promise](https://img.shields.io/gitter/room/vitaly-t/pg-promise.svg)](https://gitter.im/vitaly-t/pg-promise?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
8
-
9
6
  ---
10
7
 
11
8
  * [About](#about)
@@ -995,7 +992,8 @@ This library manages all database connections via the [connection pool], which i
995
992
  Connections in the cache expire due to inactivity after [idleTimeoutMillis] number of milliseconds, which you
996
993
  can set only when creating the [Database] object.
997
994
 
998
- While there is a single open connection in the pool, the process cannot terminate by itself, only via `process.exit()`.
995
+ While there is a single open connection in the pool, the process cannot terminate by itself, only via `process.exit()`,
996
+ unless `allowExitOnIdle` is used - see update section below.
999
997
  If you want the process to finish by itself, without waiting for all connections in the pool to expire, you need
1000
998
  to force the pool to shut down all the connections it holds:
1001
999
 
@@ -1031,7 +1029,11 @@ Once you have shut down the pool associated with your [Database] object, you can
1031
1029
  will be rejecting with [Error] = `Connection pool of the database object has been destroyed`.
1032
1030
 
1033
1031
  See the relevant API: [pgp.end], [Database.$pool]
1034
-
1032
+
1033
+ ### update
1034
+
1035
+ Version 10.11.0 added support for connection option `allowExitOnIdle`, to let process exit when pool is idle.
1036
+
1035
1037
  # History
1036
1038
 
1037
1039
  Although this project formally maintains a [CHANGELOG], for a short list of the top-level changes,
package/lib/connect.js CHANGED
@@ -40,7 +40,12 @@ function poolConnect(ctx, db, config) {
40
40
  // Make sure useCount drops to 1, if it ever reaches maximum integer number;
41
41
  // We do not drop it to zero, to avoid rerun of initialization queries that
42
42
  // usually check for useCount === 0;
43
- client.$useCount = client.$useCount >= Number.MAX_SAFE_INTEGER ? 1 : ++client.$useCount;
43
+ // istanbul ignore if
44
+ if (client.$useCount >= Number.MAX_SAFE_INTEGER) {
45
+ client.$useCount = 1; // resetting; cannot auto-test this
46
+ } else {
47
+ client.$useCount = ++client.$useCount;
48
+ }
44
49
  } else {
45
50
  Object.defineProperty(client, `$useCount`, {
46
51
  value: 0,
package/lib/formatting.js CHANGED
@@ -718,7 +718,8 @@ const $as = {
718
718
  /**
719
719
  * @method formatting.json
720
720
  * @description
721
- * Converts any value into JSON, and returns it as a valid string, with single-quote symbols fixed, unless flag `raw` is set.
721
+ * Converts any value into JSON (includes `BigInt` support), and returns it as a valid string,
722
+ * with single-quote symbols fixed, unless flag `raw` is set.
722
723
  *
723
724
  * When formatting a query, a variable makes use of this method via modifier `:json`. See method {@link formatting.format format}.
724
725
  *
package/lib/query-file.js CHANGED
@@ -229,49 +229,48 @@ class QueryFile extends InnerState {
229
229
  * Throw any error encountered.
230
230
  */
231
231
  prepare(throwErrors) {
232
- const _i = this._inner, options = _i.options;
232
+ const i = this._inner, options = i.options;
233
233
  let lastMod;
234
- if (options.debug && _i.ready) {
234
+ if (options.debug && i.ready) {
235
235
  try {
236
- lastMod = npm.fs.statSync(_i.filePath).mtime.getTime();
237
- if (lastMod === _i.modTime) {
238
- // istanbul ignore next;
239
- // coverage for this works differently under Windows and Linux
236
+ lastMod = npm.fs.statSync(i.filePath).mtime.getTime();
237
+ // istanbul ignore if;
238
+ if (lastMod === i.modTime) {
240
239
  return;
241
240
  }
242
- _i.ready = false;
241
+ i.ready = false;
243
242
  } catch (e) {
244
- _i.sql = undefined;
245
- _i.ready = false;
246
- _i.error = e;
243
+ i.sql = undefined;
244
+ i.ready = false;
245
+ i.error = e;
247
246
  if (throwErrors) {
248
- throw _i.error;
247
+ throw i.error;
249
248
  }
250
249
  return;
251
250
  }
252
251
  }
253
- if (_i.ready) {
252
+ if (i.ready) {
254
253
  return;
255
254
  }
256
255
  try {
257
- _i.sql = npm.fs.readFileSync(_i.filePath, `utf8`);
258
- _i.modTime = lastMod || npm.fs.statSync(_i.filePath).mtime.getTime();
256
+ i.sql = npm.fs.readFileSync(i.filePath, `utf8`);
257
+ i.modTime = lastMod || npm.fs.statSync(i.filePath).mtime.getTime();
259
258
  if (options.minify && options.minify !== `after`) {
260
- _i.sql = npm.minify(_i.sql, {compress: options.compress});
259
+ i.sql = npm.minify(i.sql, {compress: options.compress});
261
260
  }
262
261
  if (options.params !== undefined) {
263
- _i.sql = npm.formatting.as.format(_i.sql, options.params, {partial: true});
262
+ i.sql = npm.formatting.as.format(i.sql, options.params, {partial: true});
264
263
  }
265
264
  if (options.minify && options.minify === `after`) {
266
- _i.sql = npm.minify(_i.sql, {compress: options.compress});
265
+ i.sql = npm.minify(i.sql, {compress: options.compress});
267
266
  }
268
- _i.ready = true;
269
- _i.error = undefined;
267
+ i.ready = true;
268
+ i.error = undefined;
270
269
  } catch (e) {
271
- _i.sql = undefined;
272
- _i.error = new QueryFileError(e, this);
270
+ i.sql = undefined;
271
+ i.error = new QueryFileError(e, this);
273
272
  if (throwErrors) {
274
- throw _i.error;
273
+ throw i.error;
275
274
  }
276
275
  }
277
276
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg-promise",
3
- "version": "10.10.2",
3
+ "version": "10.12.0",
4
4
  "description": "PostgreSQL interface for Node.js",
5
5
  "main": "lib/index.js",
6
6
  "typings": "typescript/pg-promise.d.ts",
@@ -9,7 +9,6 @@
9
9
  "test:native": "jasmine-node test --config PG_NATIVE true",
10
10
  "doc": "jsdoc -c ./jsdoc/jsdoc.js ./jsdoc/README.md -t ./jsdoc/templates/custom",
11
11
  "coverage": "istanbul cover ./node_modules/jasmine-node/bin/jasmine-node test",
12
- "travis": "npm run lint && npm run tslint && npm run coverage --captureExceptions && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
13
12
  "lint": "eslint ./lib ./test/*.js ./test/db --fix",
14
13
  "tslint": "tslint ./typescript/*.ts"
15
14
  },
@@ -37,25 +36,25 @@
37
36
  },
38
37
  "license": "MIT",
39
38
  "engines": {
40
- "node": ">=8.0"
39
+ "node": ">=12.0"
41
40
  },
42
41
  "dependencies": {
43
42
  "assert-options": "0.7.0",
44
- "pg": "8.6.0",
43
+ "pg": "8.8.0",
45
44
  "pg-minify": "1.6.2",
46
45
  "spex": "3.2.0"
47
46
  },
48
47
  "devDependencies": {
49
- "@types/node": "15.0.1",
48
+ "@types/node": "18.7.13",
50
49
  "bluebird": "3.7.2",
51
- "coveralls": "3.1.0",
52
- "eslint": "7.25.0",
50
+ "coveralls": "3.1.1",
51
+ "eslint": "8.23.0",
53
52
  "istanbul": "0.4.5",
54
53
  "jasmine-node": "3.0.0",
55
- "jsdoc": "3.6.6",
54
+ "jsdoc": "3.6.11",
56
55
  "JSONStream": "1.3.5",
57
- "pg-query-stream": "4.1.0",
56
+ "pg-query-stream": "4.2.4",
58
57
  "tslint": "6.1.3",
59
- "typescript": "4.2.4"
58
+ "typescript": "4.8.2"
60
59
  }
61
60
  }
@@ -166,6 +166,7 @@ declare namespace pgPromise {
166
166
  readonly def: any;
167
167
  readonly castText: string;
168
168
  readonly escapedName: string;
169
+ readonly variable: string;
169
170
  readonly init: (col: IColumnDescriptor<T>) => any
170
171
  readonly skip: (col: IColumnDescriptor<T>) => boolean
171
172
 
@@ -13,7 +13,7 @@
13
13
  // Calling it 'pg-subset' to avoid a conflict in case the application also
14
14
  // includes the official 'pg' typings.
15
15
  //
16
- // Supported version of pg: 8.0.0 and later.
16
+ // Supported version of pg: 8.7.1 and later.
17
17
  //
18
18
  // pg: https://github.com/brianc/node-postgres
19
19
  //////////////////////////////////////////////////////////////////////////////
@@ -105,6 +105,8 @@ declare namespace pg {
105
105
  Client?: new(config: string | IConnectionParameters) => C
106
106
  Promise?: any
107
107
  types?: ITypeOverrides
108
+ allowExitOnIdle?: boolean
109
+ maxLifetimeSeconds?: number
108
110
  }
109
111
 
110
112
  // Type id-s supported by PostgreSQL, copied from: