pg 8.0.0 → 8.1.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 +42 -31
- package/lib/connection-fast.js +50 -200
- package/lib/connection-parameters.js +14 -7
- package/lib/connection.js +32 -51
- package/lib/defaults.js +1 -1
- package/lib/index.js +3 -3
- package/lib/native/client.js +8 -8
- package/lib/native/query.js +27 -22
- package/lib/query.js +44 -24
- package/lib/sasl.js +34 -30
- package/lib/type-overrides.js +7 -4
- package/lib/utils.js +43 -27
- package/package.json +6 -13
package/lib/utils.js
CHANGED
|
@@ -11,10 +11,8 @@ const crypto = require('crypto')
|
|
|
11
11
|
|
|
12
12
|
const defaults = require('./defaults')
|
|
13
13
|
|
|
14
|
-
function escapeElement
|
|
15
|
-
var escaped = elementRepresentation
|
|
16
|
-
.replace(/\\/g, '\\\\')
|
|
17
|
-
.replace(/"/g, '\\"')
|
|
14
|
+
function escapeElement(elementRepresentation) {
|
|
15
|
+
var escaped = elementRepresentation.replace(/\\/g, '\\\\').replace(/"/g, '\\"')
|
|
18
16
|
|
|
19
17
|
return '"' + escaped + '"'
|
|
20
18
|
}
|
|
@@ -22,7 +20,7 @@ function escapeElement (elementRepresentation) {
|
|
|
22
20
|
// convert a JS array to a postgres array literal
|
|
23
21
|
// uses comma separator so won't work for types like box that use
|
|
24
22
|
// a different array separator.
|
|
25
|
-
function arrayString
|
|
23
|
+
function arrayString(val) {
|
|
26
24
|
var result = '{'
|
|
27
25
|
for (var i = 0; i < val.length; i++) {
|
|
28
26
|
if (i > 0) {
|
|
@@ -76,7 +74,7 @@ var prepareValue = function (val, seen) {
|
|
|
76
74
|
return val.toString()
|
|
77
75
|
}
|
|
78
76
|
|
|
79
|
-
function prepareObject
|
|
77
|
+
function prepareObject(val, seen) {
|
|
80
78
|
if (val && typeof val.toPostgres === 'function') {
|
|
81
79
|
seen = seen || []
|
|
82
80
|
if (seen.indexOf(val) !== -1) {
|
|
@@ -89,48 +87,66 @@ function prepareObject (val, seen) {
|
|
|
89
87
|
return JSON.stringify(val)
|
|
90
88
|
}
|
|
91
89
|
|
|
92
|
-
function pad
|
|
90
|
+
function pad(number, digits) {
|
|
93
91
|
number = '' + number
|
|
94
|
-
while (number.length < digits) {
|
|
92
|
+
while (number.length < digits) {
|
|
93
|
+
number = '0' + number
|
|
94
|
+
}
|
|
95
95
|
return number
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
function dateToString
|
|
98
|
+
function dateToString(date) {
|
|
99
99
|
var offset = -date.getTimezoneOffset()
|
|
100
100
|
|
|
101
101
|
var year = date.getFullYear()
|
|
102
102
|
var isBCYear = year < 1
|
|
103
103
|
if (isBCYear) year = Math.abs(year) + 1 // negative years are 1 off their BC representation
|
|
104
104
|
|
|
105
|
-
var ret =
|
|
106
|
-
pad(
|
|
107
|
-
|
|
108
|
-
pad(date.
|
|
109
|
-
|
|
110
|
-
pad(date.
|
|
105
|
+
var ret =
|
|
106
|
+
pad(year, 4) +
|
|
107
|
+
'-' +
|
|
108
|
+
pad(date.getMonth() + 1, 2) +
|
|
109
|
+
'-' +
|
|
110
|
+
pad(date.getDate(), 2) +
|
|
111
|
+
'T' +
|
|
112
|
+
pad(date.getHours(), 2) +
|
|
113
|
+
':' +
|
|
114
|
+
pad(date.getMinutes(), 2) +
|
|
115
|
+
':' +
|
|
116
|
+
pad(date.getSeconds(), 2) +
|
|
117
|
+
'.' +
|
|
111
118
|
pad(date.getMilliseconds(), 3)
|
|
112
119
|
|
|
113
120
|
if (offset < 0) {
|
|
114
121
|
ret += '-'
|
|
115
122
|
offset *= -1
|
|
116
|
-
} else {
|
|
123
|
+
} else {
|
|
124
|
+
ret += '+'
|
|
125
|
+
}
|
|
117
126
|
|
|
118
127
|
ret += pad(Math.floor(offset / 60), 2) + ':' + pad(offset % 60, 2)
|
|
119
128
|
if (isBCYear) ret += ' BC'
|
|
120
129
|
return ret
|
|
121
130
|
}
|
|
122
131
|
|
|
123
|
-
function dateToStringUTC
|
|
132
|
+
function dateToStringUTC(date) {
|
|
124
133
|
var year = date.getUTCFullYear()
|
|
125
134
|
var isBCYear = year < 1
|
|
126
135
|
if (isBCYear) year = Math.abs(year) + 1 // negative years are 1 off their BC representation
|
|
127
136
|
|
|
128
|
-
var ret =
|
|
129
|
-
pad(
|
|
130
|
-
|
|
131
|
-
pad(date.
|
|
132
|
-
|
|
133
|
-
pad(date.
|
|
137
|
+
var ret =
|
|
138
|
+
pad(year, 4) +
|
|
139
|
+
'-' +
|
|
140
|
+
pad(date.getUTCMonth() + 1, 2) +
|
|
141
|
+
'-' +
|
|
142
|
+
pad(date.getUTCDate(), 2) +
|
|
143
|
+
'T' +
|
|
144
|
+
pad(date.getUTCHours(), 2) +
|
|
145
|
+
':' +
|
|
146
|
+
pad(date.getUTCMinutes(), 2) +
|
|
147
|
+
':' +
|
|
148
|
+
pad(date.getUTCSeconds(), 2) +
|
|
149
|
+
'.' +
|
|
134
150
|
pad(date.getUTCMilliseconds(), 3)
|
|
135
151
|
|
|
136
152
|
ret += '+00:00'
|
|
@@ -138,9 +154,9 @@ function dateToStringUTC (date) {
|
|
|
138
154
|
return ret
|
|
139
155
|
}
|
|
140
156
|
|
|
141
|
-
function normalizeQueryConfig
|
|
157
|
+
function normalizeQueryConfig(config, values, callback) {
|
|
142
158
|
// can take in strings or config objects
|
|
143
|
-
config =
|
|
159
|
+
config = typeof config === 'string' ? { text: config } : config
|
|
144
160
|
if (values) {
|
|
145
161
|
if (typeof values === 'function') {
|
|
146
162
|
config.callback = values
|
|
@@ -166,12 +182,12 @@ const postgresMd5PasswordHash = function (user, password, salt) {
|
|
|
166
182
|
}
|
|
167
183
|
|
|
168
184
|
module.exports = {
|
|
169
|
-
prepareValue: function prepareValueWrapper
|
|
185
|
+
prepareValue: function prepareValueWrapper(value) {
|
|
170
186
|
// this ensures that extra arguments do not get passed into prepareValue
|
|
171
187
|
// by accident, eg: from calling values.map(utils.prepareValue)
|
|
172
188
|
return prepareValue(value)
|
|
173
189
|
},
|
|
174
190
|
normalizeQueryConfig,
|
|
175
191
|
postgresMd5PasswordHash,
|
|
176
|
-
md5
|
|
192
|
+
md5,
|
|
177
193
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pg",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"description": "PostgreSQL client - pure javascript & libpq with the same API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"database",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"buffer-writer": "2.0.0",
|
|
23
23
|
"packet-reader": "1.0.0",
|
|
24
|
-
"pg-connection-string": "
|
|
25
|
-
"pg-
|
|
26
|
-
"pg-
|
|
24
|
+
"pg-connection-string": "^2.2.2",
|
|
25
|
+
"pg-pool": "^3.2.0",
|
|
26
|
+
"pg-protocol": "^1.2.2",
|
|
27
27
|
"pg-types": "^2.1.0",
|
|
28
28
|
"pgpass": "1.x",
|
|
29
29
|
"semver": "4.3.2"
|
|
@@ -32,18 +32,11 @@
|
|
|
32
32
|
"async": "0.9.0",
|
|
33
33
|
"bluebird": "3.5.2",
|
|
34
34
|
"co": "4.6.0",
|
|
35
|
-
"eslint": "^6.0.1",
|
|
36
|
-
"eslint-config-standard": "^13.0.1",
|
|
37
|
-
"eslint-plugin-import": "^2.18.1",
|
|
38
|
-
"eslint-plugin-node": "^9.1.0",
|
|
39
|
-
"eslint-plugin-promise": "^4.2.1",
|
|
40
|
-
"eslint-plugin-standard": "^4.0.0",
|
|
41
35
|
"pg-copy-streams": "0.3.0"
|
|
42
36
|
},
|
|
43
37
|
"minNativeVersion": "2.0.0",
|
|
44
38
|
"scripts": {
|
|
45
|
-
"test": "make test-all"
|
|
46
|
-
"lint": "make lint"
|
|
39
|
+
"test": "make test-all"
|
|
47
40
|
},
|
|
48
41
|
"files": [
|
|
49
42
|
"lib",
|
|
@@ -53,5 +46,5 @@
|
|
|
53
46
|
"engines": {
|
|
54
47
|
"node": ">= 8.0.0"
|
|
55
48
|
},
|
|
56
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "3f5bc58a86cda3b4812addc1e42a06d61d31e614"
|
|
57
50
|
}
|