pg-promise 11.4.1 → 11.4.3

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.
Files changed (43) hide show
  1. package/README.md +42 -42
  2. package/lib/assert.js +1 -1
  3. package/lib/connect.js +17 -17
  4. package/lib/database-pool.js +5 -5
  5. package/lib/database.js +37 -38
  6. package/lib/errors/index.js +4 -4
  7. package/lib/errors/parameterized-query-error.js +12 -12
  8. package/lib/errors/prepared-statement-error.js +13 -13
  9. package/lib/errors/query-file-error.js +10 -10
  10. package/lib/errors/query-result-error.js +13 -13
  11. package/lib/events.js +17 -17
  12. package/lib/formatting.js +69 -69
  13. package/lib/helpers/column-set.js +29 -29
  14. package/lib/helpers/column.js +39 -39
  15. package/lib/helpers/index.js +4 -4
  16. package/lib/helpers/methods/concat.js +9 -9
  17. package/lib/helpers/methods/index.js +5 -5
  18. package/lib/helpers/methods/insert.js +15 -15
  19. package/lib/helpers/methods/sets.js +5 -5
  20. package/lib/helpers/methods/update.js +22 -22
  21. package/lib/helpers/methods/values.js +10 -10
  22. package/lib/helpers/table-name.js +7 -7
  23. package/lib/index.js +3 -3
  24. package/lib/inner-state.js +3 -3
  25. package/lib/main.js +33 -33
  26. package/lib/patterns.js +1 -1
  27. package/lib/promise-adapter.js +12 -12
  28. package/lib/promise-parser.js +7 -7
  29. package/lib/query-file.js +21 -21
  30. package/lib/query.js +19 -19
  31. package/lib/stream.js +11 -11
  32. package/lib/task.js +29 -25
  33. package/lib/text.js +17 -17
  34. package/lib/tx-mode.js +14 -14
  35. package/lib/types/index.js +3 -3
  36. package/lib/types/parameterized-query.js +16 -16
  37. package/lib/types/prepared-statement.js +18 -18
  38. package/lib/types/server-formatting.js +3 -3
  39. package/lib/utils/color.js +1 -1
  40. package/lib/utils/index.js +20 -20
  41. package/lib/utils/public.js +26 -26
  42. package/package.json +8 -8
  43. package/typescript/README.md +1 -1
package/README.md CHANGED
@@ -1067,51 +1067,51 @@ See the relevant API: [pgp.end], [Database.$pool]
1067
1067
 
1068
1068
  <!-- Database Method Links -->
1069
1069
 
1070
- [query]:http://vitaly-t.github.io/pg-promise/Database.html#query
1071
- [none]:http://vitaly-t.github.io/pg-promise/Database.html#none
1072
- [one]:http://vitaly-t.github.io/pg-promise/Database.html#one
1073
- [oneOrNone]:http://vitaly-t.github.io/pg-promise/Database.html#oneOrNone
1074
- [many]:http://vitaly-t.github.io/pg-promise/Database.html#many
1075
- [manyOrNone]:http://vitaly-t.github.io/pg-promise/Database.html#manyOrNone
1076
- [any]:http://vitaly-t.github.io/pg-promise/Database.html#any
1077
- [result]:http://vitaly-t.github.io/pg-promise/Database.html#result
1078
- [multi]:http://vitaly-t.github.io/pg-promise/Database.html#multi
1079
- [multiResult]:http://vitaly-t.github.io/pg-promise/Database.html#multiResult
1080
- [map]:http://vitaly-t.github.io/pg-promise/Database.html#map
1081
- [each]:http://vitaly-t.github.io/pg-promise/Database.html#each
1082
- [func]:http://vitaly-t.github.io/pg-promise/Database.html#func
1083
- [proc]:http://vitaly-t.github.io/pg-promise/Database.html#proc
1084
- [stream]:http://vitaly-t.github.io/pg-promise/Database.html#stream
1085
- [connect]:http://vitaly-t.github.io/pg-promise/Database.html#connect
1086
- [task]:http://vitaly-t.github.io/pg-promise/Database.html#task
1087
- [taskIf]:http://vitaly-t.github.io/pg-promise/Database.html#taskIf
1088
- [tx]:http://vitaly-t.github.io/pg-promise/Database.html#tx
1089
- [txIf]:http://vitaly-t.github.io/pg-promise/Database.html#txIf
1090
- [batch]:http://vitaly-t.github.io/pg-promise/Task.html#batch
1091
- [sequence]:http://vitaly-t.github.io/pg-promise/Task.html#sequence
1092
- [page]:http://vitaly-t.github.io/pg-promise/Task.html#page
1093
- [extend]:http://vitaly-t.github.io/pg-promise/global.html#event:extend
1070
+ [query]:https://vitaly-t.github.io/pg-promise/Database.html#query
1071
+ [none]:https://vitaly-t.github.io/pg-promise/Database.html#none
1072
+ [one]:https://vitaly-t.github.io/pg-promise/Database.html#one
1073
+ [oneOrNone]:https://vitaly-t.github.io/pg-promise/Database.html#oneOrNone
1074
+ [many]:https://vitaly-t.github.io/pg-promise/Database.html#many
1075
+ [manyOrNone]:https://vitaly-t.github.io/pg-promise/Database.html#manyOrNone
1076
+ [any]:https://vitaly-t.github.io/pg-promise/Database.html#any
1077
+ [result]:https://vitaly-t.github.io/pg-promise/Database.html#result
1078
+ [multi]:https://vitaly-t.github.io/pg-promise/Database.html#multi
1079
+ [multiResult]:https://vitaly-t.github.io/pg-promise/Database.html#multiResult
1080
+ [map]:https://vitaly-t.github.io/pg-promise/Database.html#map
1081
+ [each]:https://vitaly-t.github.io/pg-promise/Database.html#each
1082
+ [func]:https://vitaly-t.github.io/pg-promise/Database.html#func
1083
+ [proc]:https://vitaly-t.github.io/pg-promise/Database.html#proc
1084
+ [stream]:https://vitaly-t.github.io/pg-promise/Database.html#stream
1085
+ [connect]:https://vitaly-t.github.io/pg-promise/Database.html#connect
1086
+ [task]:https://vitaly-t.github.io/pg-promise/Database.html#task
1087
+ [taskIf]:https://vitaly-t.github.io/pg-promise/Database.html#taskIf
1088
+ [tx]:https://vitaly-t.github.io/pg-promise/Database.html#tx
1089
+ [txIf]:https://vitaly-t.github.io/pg-promise/Database.html#txIf
1090
+ [batch]:https://vitaly-t.github.io/pg-promise/Task.html#batch
1091
+ [sequence]:https://vitaly-t.github.io/pg-promise/Task.html#sequence
1092
+ [page]:https://vitaly-t.github.io/pg-promise/Task.html#page
1093
+ [extend]:https://vitaly-t.github.io/pg-promise/global.html#event:extend
1094
1094
 
1095
1095
  <!-- API Links -->
1096
1096
 
1097
- [Official Documentation]:http://vitaly-t.github.io/pg-promise/index.html
1098
- [Initialization Options]:http://vitaly-t.github.io/pg-promise/module-pg-promise.html
1099
- [helpers]:http://vitaly-t.github.io/pg-promise/helpers.html
1100
- [QueryFile]:http://vitaly-t.github.io/pg-promise/QueryFile.html
1101
- [QueryFileError]:http://vitaly-t.github.io/pg-promise/errors.QueryFileError.html
1102
- [Database]:http://vitaly-t.github.io/pg-promise/Database.html
1103
- [Database.$pool]:http://vitaly-t.github.io/pg-promise/Database.html#$pool
1104
- [pgp.end]:http://vitaly-t.github.io/pg-promise/module-pg-promise.html#~end
1105
- [formatting]:http://vitaly-t.github.io/pg-promise/formatting.html
1106
- [ctf]:http://vitaly-t.github.io/pg-promise/formatting.ctf.html
1107
- [as.format]:http://vitaly-t.github.io/pg-promise/formatting.html#.format
1108
- [format]:http://vitaly-t.github.io/pg-promise/formatting.html#.format
1109
- [as.value]:http://vitaly-t.github.io/pg-promise/formatting.html#.value
1110
- [as.csv]:http://vitaly-t.github.io/pg-promise/formatting.html#.csv
1111
- [as.json]:http://vitaly-t.github.io/pg-promise/formatting.html#.json
1112
- [as.name]:http://vitaly-t.github.io/pg-promise/formatting.html#.name
1113
- [as.alias]:http://vitaly-t.github.io/pg-promise/formatting.html#.alias
1114
- [TransactionMode]:http://vitaly-t.github.io/pg-promise/txMode.TransactionMode.html
1097
+ [Official Documentation]:https://vitaly-t.github.io/pg-promise/index.html
1098
+ [Initialization Options]:https://vitaly-t.github.io/pg-promise/module-pg-promise.html
1099
+ [helpers]:https://vitaly-t.github.io/pg-promise/helpers.html
1100
+ [QueryFile]:https://vitaly-t.github.io/pg-promise/QueryFile.html
1101
+ [QueryFileError]:https://vitaly-t.github.io/pg-promise/errors.QueryFileError.html
1102
+ [Database]:https://vitaly-t.github.io/pg-promise/Database.html
1103
+ [Database.$pool]:https://vitaly-t.github.io/pg-promise/Database.html#$pool
1104
+ [pgp.end]:https://vitaly-t.github.io/pg-promise/module-pg-promise.html#~end
1105
+ [formatting]:https://vitaly-t.github.io/pg-promise/formatting.html
1106
+ [ctf]:https://vitaly-t.github.io/pg-promise/formatting.ctf.html
1107
+ [as.format]:https://vitaly-t.github.io/pg-promise/formatting.html#.format
1108
+ [format]:https://vitaly-t.github.io/pg-promise/formatting.html#.format
1109
+ [as.value]:https://vitaly-t.github.io/pg-promise/formatting.html#.value
1110
+ [as.csv]:https://vitaly-t.github.io/pg-promise/formatting.html#.csv
1111
+ [as.json]:https://vitaly-t.github.io/pg-promise/formatting.html#.json
1112
+ [as.name]:https://vitaly-t.github.io/pg-promise/formatting.html#.name
1113
+ [as.alias]:https://vitaly-t.github.io/pg-promise/formatting.html#.alias
1114
+ [TransactionMode]:https://vitaly-t.github.io/pg-promise/txMode.TransactionMode.html
1115
1115
  [PreparedStatement]:https://vitaly-t.github.io/pg-promise/PreparedStatement.html
1116
1116
  [ParameterizedQuery]:https://vitaly-t.github.io/pg-promise/ParameterizedQuery.html
1117
1117
 
package/lib/assert.js CHANGED
@@ -1,4 +1,4 @@
1
- const {assertOptions} = require(`assert-options`);
1
+ const {assertOptions} = require('assert-options');
2
2
 
3
3
  // this to allow override options-related errors globally (for pg-promise)
4
4
  global.pgPromiseAssert = assertOptions;
package/lib/connect.js CHANGED
@@ -7,13 +7,13 @@
7
7
  * Removal or modification of this copyright notice is prohibited.
8
8
  */
9
9
 
10
- const {Events} = require(`./events`);
11
- const {ColorConsole} = require(`./utils/color`);
10
+ const {Events} = require('./events');
11
+ const {ColorConsole} = require('./utils/color');
12
12
 
13
13
  const npm = {
14
- utils: require(`./utils`),
15
- text: require(`./text`),
16
- formatting: require(`./formatting`)
14
+ utils: require('./utils'),
15
+ text: require('./text'),
16
+ formatting: require('./formatting')
17
17
  };
18
18
 
19
19
  function poolConnect(ctx, db, config) {
@@ -36,7 +36,7 @@ function poolConnect(ctx, db, config) {
36
36
  });
37
37
  reject(err);
38
38
  } else {
39
- if (`$useCount` in client) {
39
+ if ('$useCount' in client) {
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;
@@ -47,7 +47,7 @@ function poolConnect(ctx, db, config) {
47
47
  client.$useCount = ++client.$useCount;
48
48
  }
49
49
  } else {
50
- Object.defineProperty(client, `$useCount`, {
50
+ Object.defineProperty(client, '$useCount', {
51
51
  value: 0,
52
52
  configurable: false,
53
53
  enumerable: false,
@@ -57,7 +57,7 @@ function poolConnect(ctx, db, config) {
57
57
  }
58
58
  setCtx(client, ctx);
59
59
  const end = lockClientEnd(client);
60
- client.on(`error`, onError);
60
+ client.on('error', onError);
61
61
  resolve({
62
62
  client,
63
63
  useCount: client.$useCount,
@@ -65,7 +65,7 @@ function poolConnect(ctx, db, config) {
65
65
  client.end = end;
66
66
  client.release(kill || client.$connectionError);
67
67
  Events.disconnect(ctx, client);
68
- client.removeListener(`error`, onError);
68
+ client.removeListener('error', onError);
69
69
  }
70
70
  });
71
71
  Events.connect(ctx, client, client.$useCount);
@@ -88,7 +88,7 @@ function directConnect(ctx, config) {
88
88
  setSchema(client, ctx);
89
89
  setCtx(client, ctx);
90
90
  const end = lockClientEnd(client);
91
- client.on(`error`, onError);
91
+ client.on('error', onError);
92
92
  resolve({
93
93
  client,
94
94
  useCount: 0,
@@ -96,7 +96,7 @@ function directConnect(ctx, config) {
96
96
  client.end = end;
97
97
  const p = config.promise((res, rej) => client.end().then(res).catch(rej));
98
98
  Events.disconnect(ctx, client);
99
- client.removeListener(`error`, onError);
99
+ client.removeListener('error', onError);
100
100
  return p;
101
101
  }
102
102
  });
@@ -113,7 +113,7 @@ function onError(err) {
113
113
  const ctx = this.$ctx;
114
114
  const cn = npm.utils.getSafeConnection(ctx.cn);
115
115
  Events.error(ctx.options, err, {cn, dc: ctx.dc});
116
- if (ctx.cnOptions && typeof ctx.cnOptions.onLost === `function` && !ctx.notified) {
116
+ if (ctx.cnOptions && typeof ctx.cnOptions.onLost === 'function' && !ctx.notified) {
117
117
  try {
118
118
  ctx.cnOptions.onLost.call(this, err, {
119
119
  cn,
@@ -143,7 +143,7 @@ function lockClientEnd(client) {
143
143
  }
144
144
 
145
145
  function setCtx(client, ctx) {
146
- Object.defineProperty(client, `$ctx`, {
146
+ Object.defineProperty(client, '$ctx', {
147
147
  value: ctx,
148
148
  writable: true
149
149
  });
@@ -154,14 +154,14 @@ function setSchema(client, ctx) {
154
154
  if (!s) {
155
155
  return;
156
156
  }
157
- if (typeof s === `function`) {
157
+ if (typeof s === 'function') {
158
158
  s = s.call(ctx.dc, ctx.dc);
159
159
  }
160
160
  if (Array.isArray(s)) {
161
- s = s.filter(a => a && typeof a === `string`);
161
+ s = s.filter(a => a && typeof a === 'string');
162
162
  }
163
- if (typeof s === `string` || (Array.isArray(s) && s.length)) {
164
- client.query(npm.formatting.as.format(`SET search_path TO $1:name`, [s]), err => {
163
+ if (typeof s === 'string' || (Array.isArray(s) && s.length)) {
164
+ client.query(npm.formatting.as.format('SET search_path TO $1:name', [s]), err => {
165
165
  // istanbul ignore if;
166
166
  if (err) {
167
167
  // This is unlikely to ever happen, unless the connection is created faulty,
@@ -7,10 +7,10 @@
7
7
  * Removal or modification of this copyright notice is prohibited.
8
8
  */
9
9
 
10
- const {ColorConsole} = require(`./utils/color`);
10
+ const {ColorConsole} = require('./utils/color');
11
11
 
12
12
  const npm = {
13
- utils: require(`./utils`)
13
+ utils: require('./utils')
14
14
  };
15
15
 
16
16
  /**
@@ -26,7 +26,7 @@ class DatabasePool {
26
26
  * @returns {{dbMap: {}, dbs: Array}}
27
27
  */
28
28
  static get instance() {
29
- const s = Symbol.for(`pgPromiseDatabasePool`);
29
+ const s = Symbol.for('pgPromiseDatabasePool');
30
30
  let scope = global[s];
31
31
  if (!scope) {
32
32
  scope = {
@@ -50,7 +50,7 @@ class DatabasePool {
50
50
  */
51
51
  static register(db) {
52
52
  const cnKey = DatabasePool.createContextKey(db);
53
- npm.utils.addReadProp(db, `$cnKey`, cnKey, true);
53
+ npm.utils.addReadProp(db, '$cnKey', cnKey, true);
54
54
  const {dbMap, dbs} = DatabasePool.instance;
55
55
  if (cnKey in dbMap) {
56
56
  dbMap[cnKey]++;
@@ -101,7 +101,7 @@ class DatabasePool {
101
101
  */
102
102
  static createContextKey(db) {
103
103
  let cn = db.$cn;
104
- if (typeof cn === `object`) {
104
+ if (typeof cn === 'object') {
105
105
  const obj = {}, keys = Object.keys(cn).sort();
106
106
  keys.forEach(name => {
107
107
  obj[name] = cn[name];
package/lib/database.js CHANGED
@@ -7,20 +7,20 @@
7
7
  * Removal or modification of this copyright notice is prohibited.
8
8
  */
9
9
 
10
- const {Events} = require(`./events`);
11
- const {assert} = require(`./assert`);
12
- const {resultQuery, multiResultQuery, streamQuery} = require(`./special-query`);
13
- const {ConnectionContext} = require(`./context`);
14
- const {DatabasePool} = require(`./database-pool`);
15
- const {queryResult} = require(`./query-result`);
10
+ const {Events} = require('./events');
11
+ const {assert} = require('./assert');
12
+ const {resultQuery, multiResultQuery, streamQuery} = require('./special-query');
13
+ const {ConnectionContext} = require('./context');
14
+ const {DatabasePool} = require('./database-pool');
15
+ const {queryResult} = require('./query-result');
16
16
 
17
17
  const npm = {
18
- utils: require(`./utils`),
19
- pubUtils: require(`./utils/public`),
20
- connect: require(`./connect`),
21
- query: require(`./query`),
22
- task: require(`./task`),
23
- text: require(`./text`)
18
+ utils: require('./utils'),
19
+ pubUtils: require('./utils/public'),
20
+ connect: require('./connect'),
21
+ query: require('./query'),
22
+ task: require('./task'),
23
+ text: require('./text')
24
24
  };
25
25
 
26
26
  /**
@@ -123,7 +123,7 @@ function Database(cn, dc, config) {
123
123
 
124
124
  const dbThis = this,
125
125
  $p = config.promise,
126
- poolConnection = typeof cn === `string` ? {connectionString: cn} : cn,
126
+ poolConnection = typeof cn === 'string' ? {connectionString: cn} : cn,
127
127
  pool = new config.pgp.pg.Pool(poolConnection),
128
128
  endMethod = pool.end;
129
129
 
@@ -135,7 +135,7 @@ function Database(cn, dc, config) {
135
135
  return res;
136
136
  };
137
137
 
138
- pool.on(`error`, onError);
138
+ pool.on('error', onError);
139
139
 
140
140
  /**
141
141
  * @method Database#connect
@@ -373,7 +373,7 @@ function Database(cn, dc, config) {
373
373
  * // call either resolve(data) or reject(reason) here
374
374
  * });
375
375
  */
376
- npm.utils.addReadProp(this, `$config`, config, true);
376
+ npm.utils.addReadProp(this, '$config', config, true);
377
377
 
378
378
  /**
379
379
  * @member {string|object} Database#$cn
@@ -385,7 +385,7 @@ function Database(cn, dc, config) {
385
385
  *
386
386
  * @see Database
387
387
  */
388
- npm.utils.addReadProp(this, `$cn`, cn, true);
388
+ npm.utils.addReadProp(this, '$cn', cn, true);
389
389
 
390
390
  /**
391
391
  * @member {*} Database#$dc
@@ -397,7 +397,7 @@ function Database(cn, dc, config) {
397
397
  *
398
398
  * @see Database
399
399
  */
400
- npm.utils.addReadProp(this, `$dc`, dc, true);
400
+ npm.utils.addReadProp(this, '$dc', dc, true);
401
401
 
402
402
  /**
403
403
  * @member {external:pg-pool} Database#$pool
@@ -428,7 +428,7 @@ function Database(cn, dc, config) {
428
428
  * .finally(db.$pool.end); // shutting down the pool
429
429
  *
430
430
  */
431
- npm.utils.addReadProp(this, `$pool`, pool, true);
431
+ npm.utils.addReadProp(this, '$pool', pool, true);
432
432
 
433
433
  /**
434
434
  * @member {function} Database.$destroy
@@ -437,13 +437,13 @@ function Database(cn, dc, config) {
437
437
  * @description
438
438
  * Permanently shuts down the database object.
439
439
  */
440
- npm.utils.addReadProp(this, `$destroy`, () => {
440
+ npm.utils.addReadProp(this, '$destroy', () => {
441
441
  if (!destroyed) {
442
442
  if (!pool.ending) {
443
443
  endMethod.call(pool);
444
444
  }
445
445
  DatabasePool.unregister(dbThis);
446
- pool.removeListener(`error`, onError);
446
+ pool.removeListener('error', onError);
447
447
  destroyed = true;
448
448
  }
449
449
  }, true);
@@ -458,7 +458,7 @@ function Database(cn, dc, config) {
458
458
 
459
459
  // Optional value-transformation helper:
460
460
  function transform(value, cb, thisArg) {
461
- return typeof cb === `function` ? value.then(data => cb.call(thisArg, data)) : value;
461
+ return typeof cb === 'function' ? value.then(data => cb.call(thisArg, data)) : value;
462
462
  }
463
463
 
464
464
  ////////////////////////////////////////////////////
@@ -981,7 +981,7 @@ function Database(cn, dc, config) {
981
981
  * {@link Database#proc proc}
982
982
  */
983
983
  obj.func = function (funcName, values, qrm) {
984
- return obj.query.call(this, {entity: funcName, type: `func`}, values, qrm);
984
+ return obj.query.call(this, {entity: funcName, type: 'func'}, values, qrm);
985
985
  };
986
986
 
987
987
  /**
@@ -1020,7 +1020,7 @@ function Database(cn, dc, config) {
1020
1020
  obj.proc = function (procName, values, cb, thisArg) {
1021
1021
  const v = obj.query.call(this, {
1022
1022
  entity: procName,
1023
- type: `proc`
1023
+ type: 'proc'
1024
1024
  }, values, queryResult.one | queryResult.none);
1025
1025
  return transform(v, cb, thisArg);
1026
1026
  };
@@ -1289,7 +1289,7 @@ function Database(cn, dc, config) {
1289
1289
  */
1290
1290
  obj.task = function () {
1291
1291
  const args = npm.pubUtils.taskArgs(arguments);
1292
- assert(args.options, [`tag`]);
1292
+ assert(args.options, ['tag']);
1293
1293
  return taskProcessor.call(this, args, false);
1294
1294
  };
1295
1295
 
@@ -1347,11 +1347,11 @@ function Database(cn, dc, config) {
1347
1347
  */
1348
1348
  obj.taskIf = function () {
1349
1349
  const args = npm.pubUtils.taskArgs(arguments);
1350
- assert(args.options, [`tag`, `cnd`]);
1350
+ assert(args.options, ['tag', 'cnd']);
1351
1351
  try {
1352
1352
  let cnd = args.options.cnd;
1353
- if (`cnd` in args.options) {
1354
- cnd = typeof cnd === `function` ? cnd.call(obj, obj) : !!cnd;
1353
+ if ('cnd' in args.options) {
1354
+ cnd = typeof cnd === 'function' ? cnd.call(obj, obj) : !!cnd;
1355
1355
  } else {
1356
1356
  cnd = !obj.ctx; // create task, if it is the top level
1357
1357
  }
@@ -1456,7 +1456,7 @@ function Database(cn, dc, config) {
1456
1456
  */
1457
1457
  obj.tx = function () {
1458
1458
  const args = npm.pubUtils.taskArgs(arguments);
1459
- assert(args.options, [`tag`, `mode`]);
1459
+ assert(args.options, ['tag', 'mode']);
1460
1460
  return taskProcessor.call(this, args, true);
1461
1461
  };
1462
1462
 
@@ -1525,22 +1525,21 @@ function Database(cn, dc, config) {
1525
1525
  * {@link Database#taskIf Database.taskIf},
1526
1526
  * {@link Database#tx Database.tx},
1527
1527
  * {@link TaskContext}
1528
- *
1529
1528
  */
1530
1529
  obj.txIf = function () {
1531
1530
  const args = npm.pubUtils.taskArgs(arguments);
1532
- assert(args.options, [`tag`, `mode`, `cnd`, `reusable`]);
1531
+ assert(args.options, ['tag', 'mode', 'cnd', 'reusable']);
1533
1532
  try {
1534
1533
  let cnd;
1535
- if (`cnd` in args.options) {
1534
+ if ('cnd' in args.options) {
1536
1535
  cnd = args.options.cnd;
1537
- cnd = typeof cnd === `function` ? cnd.call(obj, obj) : !!cnd;
1536
+ cnd = typeof cnd === 'function' ? cnd.call(obj, obj) : !!cnd;
1538
1537
  } else {
1539
1538
  cnd = !obj.ctx || !obj.ctx.inTransaction;
1540
1539
  }
1541
1540
  args.options.cnd = cnd;
1542
1541
  const reusable = args.options.reusable;
1543
- args.options.reusable = !cnd && obj.ctx && typeof reusable === `function` ? reusable.call(obj, obj) : !!reusable;
1542
+ args.options.reusable = !cnd && obj.ctx && typeof reusable === 'function' ? reusable.call(obj, obj) : !!reusable;
1544
1543
  } catch (e) {
1545
1544
  return $p.reject(e);
1546
1545
  }
@@ -1551,8 +1550,8 @@ function Database(cn, dc, config) {
1551
1550
  // Resolves with result from the callback function;
1552
1551
  function taskProcessor(params, isTX) {
1553
1552
 
1554
- if (typeof params.cb !== `function`) {
1555
- return $p.reject(new TypeError(`Callback function is required.`));
1553
+ if (typeof params.cb !== 'function') {
1554
+ return $p.reject(new TypeError('Callback function is required.'));
1556
1555
  }
1557
1556
 
1558
1557
  if (params.options.reusable) {
@@ -1577,7 +1576,7 @@ function Database(cn, dc, config) {
1577
1576
 
1578
1577
  if (taskCtx.db) {
1579
1578
  // reuse existing connection;
1580
- npm.utils.addReadProp(tsk.ctx, `useCount`, taskCtx.db.useCount);
1579
+ npm.utils.addReadProp(tsk.ctx, 'useCount', taskCtx.db.useCount);
1581
1580
  addServerVersion(tsk.ctx, taskCtx.db.client);
1582
1581
  return config.$npm.task.execute(taskCtx, tsk, isTX, config);
1583
1582
  }
@@ -1586,7 +1585,7 @@ function Database(cn, dc, config) {
1586
1585
  return config.$npm.connect.pool(taskCtx, dbThis)
1587
1586
  .then(db => {
1588
1587
  taskCtx.connect(db);
1589
- npm.utils.addReadProp(tsk.ctx, `useCount`, db.useCount);
1588
+ npm.utils.addReadProp(tsk.ctx, 'useCount', db.useCount);
1590
1589
  addServerVersion(tsk.ctx, db.client);
1591
1590
  return config.$npm.task.execute(taskCtx, tsk, isTX, config);
1592
1591
  })
@@ -1604,7 +1603,7 @@ function Database(cn, dc, config) {
1604
1603
  // Exclude else-case from coverage, because it can only occur with Native Bindings.
1605
1604
  // istanbul ignore else
1606
1605
  if (client.serverVersion) {
1607
- npm.utils.addReadProp(target, `serverVersion`, client.serverVersion);
1606
+ npm.utils.addReadProp(target, 'serverVersion', client.serverVersion);
1608
1607
  }
1609
1608
  }
1610
1609
 
@@ -7,10 +7,10 @@
7
7
  * Removal or modification of this copyright notice is prohibited.
8
8
  */
9
9
 
10
- const {QueryResultError, queryResultErrorCode} = require(`./query-result-error`);
11
- const {PreparedStatementError} = require(`./prepared-statement-error`);
12
- const {ParameterizedQueryError} = require(`./parameterized-query-error`);
13
- const {QueryFileError} = require(`./query-file-error`);
10
+ const {QueryResultError, queryResultErrorCode} = require('./query-result-error');
11
+ const {PreparedStatementError} = require('./prepared-statement-error');
12
+ const {ParameterizedQueryError} = require('./parameterized-query-error');
13
+ const {QueryFileError} = require('./query-file-error');
14
14
 
15
15
  /**
16
16
  * @namespace errors
@@ -7,11 +7,11 @@
7
7
  * Removal or modification of this copyright notice is prohibited.
8
8
  */
9
9
 
10
- const {QueryFileError} = require(`./query-file-error`);
10
+ const {QueryFileError} = require('./query-file-error');
11
11
 
12
12
  const npm = {
13
- os: require(`os`),
14
- utils: require(`../utils`)
13
+ os: require('os'),
14
+ utils: require('../utils')
15
15
  };
16
16
 
17
17
  /**
@@ -45,7 +45,7 @@ const npm = {
45
45
  class ParameterizedQueryError extends Error {
46
46
  constructor(error, pq) {
47
47
  const isQueryFileError = error instanceof QueryFileError;
48
- const message = isQueryFileError ? `Failed to initialize 'text' from a QueryFile.` : error;
48
+ const message = isQueryFileError ? 'Failed to initialize \'text\' from a QueryFile.' : error;
49
49
  super(message);
50
50
  this.name = this.constructor.name;
51
51
  if (isQueryFileError) {
@@ -74,17 +74,17 @@ ParameterizedQueryError.prototype.toString = function (level) {
74
74
  gap1 = npm.utils.messageGap(level + 1),
75
75
  gap2 = npm.utils.messageGap(level + 2),
76
76
  lines = [
77
- `ParameterizedQueryError {`,
78
- gap1 + `message: "` + this.message + `"`,
79
- gap1 + `result: {`,
80
- gap2 + `text: ` + npm.utils.toJson(this.result.text),
81
- gap2 + `values: ` + npm.utils.toJson(this.result.values),
82
- gap1 + `}`
77
+ 'ParameterizedQueryError {',
78
+ gap1 + 'message: "' + this.message + '"',
79
+ gap1 + 'result: {',
80
+ gap2 + 'text: ' + npm.utils.toJson(this.result.text),
81
+ gap2 + 'values: ' + npm.utils.toJson(this.result.values),
82
+ gap1 + '}'
83
83
  ];
84
84
  if (this.error) {
85
- lines.push(gap1 + `error: ` + this.error.toString(level + 1));
85
+ lines.push(gap1 + 'error: ' + this.error.toString(level + 1));
86
86
  }
87
- lines.push(gap0 + `}`);
87
+ lines.push(gap0 + '}');
88
88
  return lines.join(npm.os.EOL);
89
89
  };
90
90
 
@@ -7,11 +7,11 @@
7
7
  * Removal or modification of this copyright notice is prohibited.
8
8
  */
9
9
 
10
- const {QueryFileError} = require(`./query-file-error`);
10
+ const {QueryFileError} = require('./query-file-error');
11
11
 
12
12
  const npm = {
13
- os: require(`os`),
14
- utils: require(`../utils`)
13
+ os: require('os'),
14
+ utils: require('../utils')
15
15
  };
16
16
 
17
17
  /**
@@ -45,7 +45,7 @@ const npm = {
45
45
  class PreparedStatementError extends Error {
46
46
  constructor(error, ps) {
47
47
  const isQueryFileError = error instanceof QueryFileError;
48
- const message = isQueryFileError ? `Failed to initialize 'text' from a QueryFile.` : error;
48
+ const message = isQueryFileError ? 'Failed to initialize \'text\' from a QueryFile.' : error;
49
49
  super(message);
50
50
  this.name = this.constructor.name;
51
51
  if (isQueryFileError) {
@@ -74,18 +74,18 @@ PreparedStatementError.prototype.toString = function (level) {
74
74
  gap1 = npm.utils.messageGap(level + 1),
75
75
  gap2 = npm.utils.messageGap(level + 2),
76
76
  lines = [
77
- `PreparedStatementError {`,
78
- gap1 + `message: "` + this.message + `"`,
79
- gap1 + `result: {`,
80
- gap2 + `name: ` + npm.utils.toJson(this.result.name),
81
- gap2 + `text: ` + npm.utils.toJson(this.result.text),
82
- gap2 + `values: ` + npm.utils.toJson(this.result.values),
83
- gap1 + `}`
77
+ 'PreparedStatementError {',
78
+ gap1 + 'message: "' + this.message + '"',
79
+ gap1 + 'result: {',
80
+ gap2 + 'name: ' + npm.utils.toJson(this.result.name),
81
+ gap2 + 'text: ' + npm.utils.toJson(this.result.text),
82
+ gap2 + 'values: ' + npm.utils.toJson(this.result.values),
83
+ gap1 + '}'
84
84
  ];
85
85
  if (this.error) {
86
- lines.push(gap1 + `error: ` + this.error.toString(level + 1));
86
+ lines.push(gap1 + 'error: ' + this.error.toString(level + 1));
87
87
  }
88
- lines.push(gap0 + `}`);
88
+ lines.push(gap0 + '}');
89
89
  return lines.join(npm.os.EOL);
90
90
  };
91
91
 
@@ -8,9 +8,9 @@
8
8
  */
9
9
 
10
10
  const npm = {
11
- os: require(`os`),
12
- utils: require(`../utils`),
13
- minify: require(`pg-minify`)
11
+ os: require('os'),
12
+ utils: require('../utils'),
13
+ minify: require('pg-minify')
14
14
  };
15
15
 
16
16
  /**
@@ -47,7 +47,7 @@ const npm = {
47
47
  class QueryFileError extends Error {
48
48
  constructor(error, qf) {
49
49
  const isSqlError = error instanceof npm.minify.SQLParsingError;
50
- const message = isSqlError ? `Failed to parse the SQL.` : error.message;
50
+ const message = isSqlError ? 'Failed to parse the SQL.' : error.message;
51
51
  super(message);
52
52
  this.name = this.constructor.name;
53
53
  if (isSqlError) {
@@ -76,15 +76,15 @@ QueryFileError.prototype.toString = function (level) {
76
76
  const gap0 = npm.utils.messageGap(level),
77
77
  gap1 = npm.utils.messageGap(level + 1),
78
78
  lines = [
79
- `QueryFileError {`,
80
- gap1 + `message: "` + this.message + `"`,
81
- gap1 + `options: ` + npm.utils.toJson(this.options),
82
- gap1 + `file: "` + this.file + `"`
79
+ 'QueryFileError {',
80
+ gap1 + 'message: "' + this.message + '"',
81
+ gap1 + 'options: ' + npm.utils.toJson(this.options),
82
+ gap1 + 'file: "' + this.file + '"'
83
83
  ];
84
84
  if (this.error) {
85
- lines.push(gap1 + `error: ` + this.error.toString(level + 1));
85
+ lines.push(gap1 + 'error: ' + this.error.toString(level + 1));
86
86
  }
87
- lines.push(gap0 + `}`);
87
+ lines.push(gap0 + '}');
88
88
  return lines.join(npm.os.EOL);
89
89
  };
90
90