pg 8.18.0 → 8.19.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/lib/client.js +21 -11
- package/lib/native/client.js +18 -3
- package/package.json +4 -4
package/lib/client.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
1
|
const EventEmitter = require('events').EventEmitter
|
|
4
2
|
const utils = require('./utils')
|
|
5
3
|
const nodeUtils = require('util')
|
|
@@ -14,23 +12,28 @@ const crypto = require('./crypto/utils')
|
|
|
14
12
|
|
|
15
13
|
const activeQueryDeprecationNotice = nodeUtils.deprecate(
|
|
16
14
|
() => {},
|
|
17
|
-
'Client.activeQuery is deprecated and will be removed in
|
|
15
|
+
'Client.activeQuery is deprecated and will be removed in pg@9.0'
|
|
18
16
|
)
|
|
19
17
|
|
|
20
18
|
const queryQueueDeprecationNotice = nodeUtils.deprecate(
|
|
21
19
|
() => {},
|
|
22
|
-
'Client.queryQueue is deprecated and will be removed in
|
|
20
|
+
'Client.queryQueue is deprecated and will be removed in pg@9.0.'
|
|
23
21
|
)
|
|
24
22
|
|
|
25
23
|
const pgPassDeprecationNotice = nodeUtils.deprecate(
|
|
26
24
|
() => {},
|
|
27
|
-
'pgpass support is deprecated and will be removed in
|
|
28
|
-
'You can provide an async function as the password property to the Client/Pool constructor that returns a password instead. Within this
|
|
25
|
+
'pgpass support is deprecated and will be removed in pg@9.0. ' +
|
|
26
|
+
'You can provide an async function as the password property to the Client/Pool constructor that returns a password instead. Within this function you can call the pgpass module in your own code.'
|
|
29
27
|
)
|
|
30
28
|
|
|
31
29
|
const byoPromiseDeprecationNotice = nodeUtils.deprecate(
|
|
32
30
|
() => {},
|
|
33
|
-
'Passing a custom Promise implementation to the Client/Pool constructor is deprecated and will be removed in
|
|
31
|
+
'Passing a custom Promise implementation to the Client/Pool constructor is deprecated and will be removed in pg@9.0.'
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
const queryQueueLengthDeprecationNotice = nodeUtils.deprecate(
|
|
35
|
+
() => {},
|
|
36
|
+
'Calling client.query() when the client is already executing a query is deprecated and will be removed in pg@9.0. Use asycn/await or an external async flow control mechanism instead.'
|
|
34
37
|
)
|
|
35
38
|
|
|
36
39
|
class Client extends EventEmitter {
|
|
@@ -249,7 +252,7 @@ class Client extends EventEmitter {
|
|
|
249
252
|
if (typeof this.password === 'function') {
|
|
250
253
|
this._Promise
|
|
251
254
|
.resolve()
|
|
252
|
-
.then(() => this.password())
|
|
255
|
+
.then(() => this.password(this.connectionParameters))
|
|
253
256
|
.then((pass) => {
|
|
254
257
|
if (pass !== undefined) {
|
|
255
258
|
if (typeof pass !== 'string') {
|
|
@@ -609,8 +612,12 @@ class Client extends EventEmitter {
|
|
|
609
612
|
} else if (typeof config.submit === 'function') {
|
|
610
613
|
readTimeout = config.query_timeout || this.connectionParameters.query_timeout
|
|
611
614
|
result = query = config
|
|
612
|
-
if (
|
|
613
|
-
|
|
615
|
+
if (!query.callback) {
|
|
616
|
+
if (typeof values === 'function') {
|
|
617
|
+
query.callback = values
|
|
618
|
+
} else if (callback) {
|
|
619
|
+
query.callback = callback
|
|
620
|
+
}
|
|
614
621
|
}
|
|
615
622
|
} else {
|
|
616
623
|
readTimeout = config.query_timeout || this.connectionParameters.query_timeout
|
|
@@ -628,7 +635,7 @@ class Client extends EventEmitter {
|
|
|
628
635
|
}
|
|
629
636
|
|
|
630
637
|
if (readTimeout) {
|
|
631
|
-
queryCallback = query.callback
|
|
638
|
+
queryCallback = query.callback || (() => {})
|
|
632
639
|
|
|
633
640
|
readTimeoutTimer = setTimeout(() => {
|
|
634
641
|
const error = new Error('Query read timeout')
|
|
@@ -680,6 +687,9 @@ class Client extends EventEmitter {
|
|
|
680
687
|
return result
|
|
681
688
|
}
|
|
682
689
|
|
|
690
|
+
if (this._queryQueue.length > 0) {
|
|
691
|
+
queryQueueLengthDeprecationNotice()
|
|
692
|
+
}
|
|
683
693
|
this._queryQueue.push(query)
|
|
684
694
|
this._pulseQueryQueue()
|
|
685
695
|
return result
|
package/lib/native/client.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const nodeUtils = require('util')
|
|
3
2
|
// eslint-disable-next-line
|
|
4
3
|
var Native
|
|
5
4
|
// eslint-disable-next-line no-useless-catch
|
|
@@ -16,6 +15,11 @@ const ConnectionParameters = require('../connection-parameters')
|
|
|
16
15
|
|
|
17
16
|
const NativeQuery = require('./query')
|
|
18
17
|
|
|
18
|
+
const queryQueueLengthDeprecationNotice = nodeUtils.deprecate(
|
|
19
|
+
() => {},
|
|
20
|
+
'Calling client.query() when the client is already executing a query is deprecated and will be removed in pg@9.0. Use asycn/await or an external async flow control mechanism instead.'
|
|
21
|
+
)
|
|
22
|
+
|
|
19
23
|
const Client = (module.exports = function (config) {
|
|
20
24
|
EventEmitter.call(this)
|
|
21
25
|
config = config || {}
|
|
@@ -184,7 +188,7 @@ Client.prototype.query = function (config, values, callback) {
|
|
|
184
188
|
}
|
|
185
189
|
|
|
186
190
|
if (readTimeout) {
|
|
187
|
-
queryCallback = query.callback
|
|
191
|
+
queryCallback = query.callback || (() => {})
|
|
188
192
|
|
|
189
193
|
readTimeoutTimer = setTimeout(() => {
|
|
190
194
|
const error = new Error('Query read timeout')
|
|
@@ -230,6 +234,10 @@ Client.prototype.query = function (config, values, callback) {
|
|
|
230
234
|
return result
|
|
231
235
|
}
|
|
232
236
|
|
|
237
|
+
if (this._queryQueue.length > 0) {
|
|
238
|
+
queryQueueLengthDeprecationNotice()
|
|
239
|
+
}
|
|
240
|
+
|
|
233
241
|
this._queryQueue.push(query)
|
|
234
242
|
this._pulseQueryQueue()
|
|
235
243
|
return result
|
|
@@ -250,7 +258,10 @@ Client.prototype.end = function (cb) {
|
|
|
250
258
|
cb = (err) => (err ? reject(err) : resolve())
|
|
251
259
|
})
|
|
252
260
|
}
|
|
261
|
+
|
|
253
262
|
this.native.end(function () {
|
|
263
|
+
self._connected = false
|
|
264
|
+
|
|
254
265
|
self._errorAllQueries(new Error('Connection terminated'))
|
|
255
266
|
|
|
256
267
|
process.nextTick(() => {
|
|
@@ -306,3 +317,7 @@ Client.prototype.setTypeParser = function (oid, format, parseFn) {
|
|
|
306
317
|
Client.prototype.getTypeParser = function (oid, format) {
|
|
307
318
|
return this._types.getTypeParser(oid, format)
|
|
308
319
|
}
|
|
320
|
+
|
|
321
|
+
Client.prototype.isConnected = function () {
|
|
322
|
+
return this._connected
|
|
323
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pg",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.19.0",
|
|
4
4
|
"description": "PostgreSQL client - pure javascript & libpq with the same API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"database",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"pg-connection-string": "^2.11.0",
|
|
36
|
-
"pg-pool": "^3.
|
|
37
|
-
"pg-protocol": "^1.
|
|
36
|
+
"pg-pool": "^3.12.0",
|
|
37
|
+
"pg-protocol": "^1.12.0",
|
|
38
38
|
"pg-types": "2.2.0",
|
|
39
39
|
"pgpass": "1.0.5"
|
|
40
40
|
},
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"engines": {
|
|
73
73
|
"node": ">= 16.0.0"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "f2d7d1146cc87024a5fa503dce13c59ff5196d26"
|
|
76
76
|
}
|