pg 8.17.0 → 8.17.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/lib/client.js +1 -1
- package/lib/connection-parameters.js +5 -1
- package/lib/connection.js +0 -1
- package/lib/defaults.js +8 -1
- package/lib/index.js +33 -24
- package/package.json +3 -3
package/lib/client.js
CHANGED
|
@@ -7,6 +7,10 @@ const defaults = require('./defaults')
|
|
|
7
7
|
const parse = require('pg-connection-string').parse // parses a connection string
|
|
8
8
|
|
|
9
9
|
const val = function (key, config, envVar) {
|
|
10
|
+
if (config[key]) {
|
|
11
|
+
return config[key]
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
if (envVar === undefined) {
|
|
11
15
|
envVar = process.env['PG' + key.toUpperCase()]
|
|
12
16
|
} else if (envVar === false) {
|
|
@@ -15,7 +19,7 @@ const val = function (key, config, envVar) {
|
|
|
15
19
|
envVar = process.env[envVar]
|
|
16
20
|
}
|
|
17
21
|
|
|
18
|
-
return
|
|
22
|
+
return envVar || defaults[key]
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
const readSSLConfigFromEnvironment = function () {
|
package/lib/connection.js
CHANGED
|
@@ -22,7 +22,6 @@ class Connection extends EventEmitter {
|
|
|
22
22
|
|
|
23
23
|
this._keepAlive = config.keepAlive
|
|
24
24
|
this._keepAliveInitialDelayMillis = config.keepAliveInitialDelayMillis
|
|
25
|
-
this.lastBuffer = false
|
|
26
25
|
this.parsedStatements = {}
|
|
27
26
|
this.ssl = config.ssl || false
|
|
28
27
|
this._ending = false
|
package/lib/defaults.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
let user
|
|
4
|
+
try {
|
|
5
|
+
user = process.platform === 'win32' ? process.env.USERNAME : process.env.USER
|
|
6
|
+
} catch {
|
|
7
|
+
// ignore, e.g., Deno without --allow-env
|
|
8
|
+
}
|
|
9
|
+
|
|
3
10
|
module.exports = {
|
|
4
11
|
// database host. defaults to localhost
|
|
5
12
|
host: 'localhost',
|
|
6
13
|
|
|
7
14
|
// database user's name
|
|
8
|
-
user
|
|
15
|
+
user,
|
|
9
16
|
|
|
10
17
|
// name of database to connect
|
|
11
18
|
database: undefined,
|
package/lib/index.js
CHANGED
|
@@ -34,31 +34,40 @@ const PG = function (clientConstructor) {
|
|
|
34
34
|
this.utils = utils
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
module.exports = new PG(require('./native'))
|
|
39
|
-
} else {
|
|
40
|
-
module.exports = new PG(Client)
|
|
37
|
+
let clientConstructor = Client
|
|
41
38
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
39
|
+
let forceNative = false
|
|
40
|
+
try {
|
|
41
|
+
forceNative = !!process.env.NODE_PG_FORCE_NATIVE
|
|
42
|
+
} catch {
|
|
43
|
+
// ignore, e.g., Deno without --allow-env
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (forceNative) {
|
|
47
|
+
clientConstructor = require('./native')
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module.exports = new PG(clientConstructor)
|
|
51
|
+
|
|
52
|
+
// lazy require native module...the native module may not have installed
|
|
53
|
+
Object.defineProperty(module.exports, 'native', {
|
|
54
|
+
configurable: true,
|
|
55
|
+
enumerable: false,
|
|
56
|
+
get() {
|
|
57
|
+
let native = null
|
|
58
|
+
try {
|
|
59
|
+
native = new PG(require('./native'))
|
|
60
|
+
} catch (err) {
|
|
61
|
+
if (err.code !== 'MODULE_NOT_FOUND') {
|
|
62
|
+
throw err
|
|
54
63
|
}
|
|
64
|
+
}
|
|
55
65
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
66
|
+
// overwrite module.exports.native so that getter is never called again
|
|
67
|
+
Object.defineProperty(module.exports, 'native', {
|
|
68
|
+
value: native,
|
|
69
|
+
})
|
|
60
70
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
71
|
+
return native
|
|
72
|
+
},
|
|
73
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pg",
|
|
3
|
-
"version": "8.17.
|
|
3
|
+
"version": "8.17.2",
|
|
4
4
|
"description": "PostgreSQL client - pure javascript & libpq with the same API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"database",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"./lib/*.js": "./lib/*.js"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"pg-connection-string": "^2.10.
|
|
35
|
+
"pg-connection-string": "^2.10.1",
|
|
36
36
|
"pg-pool": "^3.11.0",
|
|
37
37
|
"pg-protocol": "^1.11.0",
|
|
38
38
|
"pg-types": "2.2.0",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"engines": {
|
|
73
73
|
"node": ">= 16.0.0"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "5b68a115cc90a7b7069fa8c4b0ca51e3447367e9"
|
|
76
76
|
}
|