pg 8.13.0 → 8.13.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/query.js CHANGED
@@ -65,7 +65,7 @@ class Query extends EventEmitter {
65
65
  if (!Array.isArray(this._results)) {
66
66
  this._results = [this._result]
67
67
  }
68
- this._result = new Result(this._rowMode, this.types)
68
+ this._result = new Result(this._rowMode, this._result._types)
69
69
  this._results.push(this._result)
70
70
  }
71
71
  }
package/lib/result.js CHANGED
@@ -37,7 +37,7 @@ class Result {
37
37
  if (match) {
38
38
  this.command = match[1]
39
39
  if (match[3]) {
40
- // COMMMAND OID ROWS
40
+ // COMMAND OID ROWS
41
41
  this.oid = parseInt(match[2], 10)
42
42
  this.rowCount = parseInt(match[3], 10)
43
43
  } else if (match[2]) {
@@ -88,11 +88,11 @@ class Result {
88
88
  this._parsers = new Array(fieldDescriptions.length)
89
89
  }
90
90
 
91
- var row = {}
91
+ this._prebuiltEmptyResultObject = {}
92
92
 
93
93
  for (var i = 0; i < fieldDescriptions.length; i++) {
94
94
  var desc = fieldDescriptions[i]
95
- row[desc.name] = null
95
+ this._prebuiltEmptyResultObject[desc.name] = null
96
96
 
97
97
  if (this._types) {
98
98
  this._parsers[i] = this._types.getTypeParser(desc.dataTypeID, desc.format || 'text')
@@ -100,7 +100,6 @@ class Result {
100
100
  this._parsers[i] = types.getTypeParser(desc.dataTypeID, desc.format || 'text')
101
101
  }
102
102
  }
103
- this._prebuiltEmptyResultObject = { ...row }
104
103
  }
105
104
  }
106
105
 
package/lib/utils.js CHANGED
@@ -49,27 +49,28 @@ var prepareValue = function (val, seen) {
49
49
  if (val == null) {
50
50
  return null
51
51
  }
52
- if (val instanceof Buffer) {
53
- return val
54
- }
55
- if (ArrayBuffer.isView(val)) {
56
- var buf = Buffer.from(val.buffer, val.byteOffset, val.byteLength)
57
- if (buf.length === val.byteLength) {
58
- return buf
52
+ if (typeof val === 'object') {
53
+ if (val instanceof Buffer) {
54
+ return val
59
55
  }
60
- return buf.slice(val.byteOffset, val.byteOffset + val.byteLength) // Node.js v4 does not support those Buffer.from params
61
- }
62
- if (val instanceof Date) {
63
- if (defaults.parseInputDatesAsUTC) {
64
- return dateToStringUTC(val)
65
- } else {
66
- return dateToString(val)
56
+ if (ArrayBuffer.isView(val)) {
57
+ var buf = Buffer.from(val.buffer, val.byteOffset, val.byteLength)
58
+ if (buf.length === val.byteLength) {
59
+ return buf
60
+ }
61
+ return buf.slice(val.byteOffset, val.byteOffset + val.byteLength) // Node.js v4 does not support those Buffer.from params
67
62
  }
68
- }
69
- if (Array.isArray(val)) {
70
- return arrayString(val)
71
- }
72
- if (typeof val === 'object') {
63
+ if (val instanceof Date) {
64
+ if (defaults.parseInputDatesAsUTC) {
65
+ return dateToStringUTC(val)
66
+ } else {
67
+ return dateToString(val)
68
+ }
69
+ }
70
+ if (Array.isArray(val)) {
71
+ return arrayString(val)
72
+ }
73
+
73
74
  return prepareObject(val, seen)
74
75
  }
75
76
  return val.toString()
@@ -88,14 +89,6 @@ function prepareObject(val, seen) {
88
89
  return JSON.stringify(val)
89
90
  }
90
91
 
91
- function pad(number, digits) {
92
- number = '' + number
93
- while (number.length < digits) {
94
- number = '0' + number
95
- }
96
- return number
97
- }
98
-
99
92
  function dateToString(date) {
100
93
  var offset = -date.getTimezoneOffset()
101
94
 
@@ -104,19 +97,19 @@ function dateToString(date) {
104
97
  if (isBCYear) year = Math.abs(year) + 1 // negative years are 1 off their BC representation
105
98
 
106
99
  var ret =
107
- pad(year, 4) +
100
+ String(year).padStart(4, '0') +
108
101
  '-' +
109
- pad(date.getMonth() + 1, 2) +
102
+ String(date.getMonth() + 1).padStart(2, '0') +
110
103
  '-' +
111
- pad(date.getDate(), 2) +
104
+ String(date.getDate()).padStart(2, '0') +
112
105
  'T' +
113
- pad(date.getHours(), 2) +
106
+ String(date.getHours()).padStart(2, '0') +
114
107
  ':' +
115
- pad(date.getMinutes(), 2) +
108
+ String(date.getMinutes()).padStart(2, '0') +
116
109
  ':' +
117
- pad(date.getSeconds(), 2) +
110
+ String(date.getSeconds()).padStart(2, '0') +
118
111
  '.' +
119
- pad(date.getMilliseconds(), 3)
112
+ String(date.getMilliseconds()).padStart(3, '0')
120
113
 
121
114
  if (offset < 0) {
122
115
  ret += '-'
@@ -125,7 +118,7 @@ function dateToString(date) {
125
118
  ret += '+'
126
119
  }
127
120
 
128
- ret += pad(Math.floor(offset / 60), 2) + ':' + pad(offset % 60, 2)
121
+ ret += String(Math.floor(offset / 60)).padStart(2, '0') + ':' + String(offset % 60).padStart(2, '0')
129
122
  if (isBCYear) ret += ' BC'
130
123
  return ret
131
124
  }
@@ -136,19 +129,19 @@ function dateToStringUTC(date) {
136
129
  if (isBCYear) year = Math.abs(year) + 1 // negative years are 1 off their BC representation
137
130
 
138
131
  var ret =
139
- pad(year, 4) +
132
+ String(year).padStart(4, '0') +
140
133
  '-' +
141
- pad(date.getUTCMonth() + 1, 2) +
134
+ String(date.getUTCMonth() + 1).padStart(2, '0') +
142
135
  '-' +
143
- pad(date.getUTCDate(), 2) +
136
+ String(date.getUTCDate()).padStart(2, '0') +
144
137
  'T' +
145
- pad(date.getUTCHours(), 2) +
138
+ String(date.getUTCHours()).padStart(2, '0') +
146
139
  ':' +
147
- pad(date.getUTCMinutes(), 2) +
140
+ String(date.getUTCMinutes()).padStart(2, '0') +
148
141
  ':' +
149
- pad(date.getUTCSeconds(), 2) +
142
+ String(date.getUTCSeconds()).padStart(2, '0') +
150
143
  '.' +
151
- pad(date.getUTCMilliseconds(), 3)
144
+ String(date.getUTCMilliseconds()).padStart(3, '0')
152
145
 
153
146
  ret += '+00:00'
154
147
  if (isBCYear) ret += ' BC'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg",
3
- "version": "8.13.0",
3
+ "version": "8.13.2",
4
4
  "description": "PostgreSQL client - pure javascript & libpq with the same API",
5
5
  "keywords": [
6
6
  "database",
@@ -21,8 +21,8 @@
21
21
  "main": "./lib",
22
22
  "dependencies": {
23
23
  "pg-connection-string": "^2.7.0",
24
- "pg-pool": "^3.7.0",
25
- "pg-protocol": "^1.7.0",
24
+ "pg-pool": "^3.7.1",
25
+ "pg-protocol": "^1.7.1",
26
26
  "pg-types": "^2.1.0",
27
27
  "pgpass": "1.x"
28
28
  },
@@ -58,5 +58,5 @@
58
58
  "engines": {
59
59
  "node": ">= 8.0.0"
60
60
  },
61
- "gitHead": "92cb640fd316972e323ced6256b2acd89b1b58e0"
61
+ "gitHead": "732580782ffa2f9299f7112ff27cfa4534cd22f3"
62
62
  }