pg-promise 12.5.0 → 12.6.1
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/errors/parameterized-query-error.js +9 -33
- package/lib/errors/prepared-statement-error.js +9 -34
- package/lib/errors/query-file-error.js +10 -30
- package/lib/errors/query-result-error.js +13 -33
- package/lib/helpers/column-set.js +1 -40
- package/lib/helpers/column.js +0 -49
- package/lib/helpers/table-name.js +0 -6
- package/lib/query-file.js +11 -30
- package/lib/tx-mode.js +9 -5
- package/lib/types/parameterized-query.js +11 -27
- package/lib/types/prepared-statement.js +17 -32
- package/lib/types/server-formatting.js +0 -5
- package/lib/utils/index.js +0 -7
- package/package.json +6 -6
|
@@ -11,7 +11,8 @@ const {QueryFileError} = require('./query-file-error');
|
|
|
11
11
|
|
|
12
12
|
const npm = {
|
|
13
13
|
os: require('os'),
|
|
14
|
-
utils: require('../utils')
|
|
14
|
+
utils: require('../utils'),
|
|
15
|
+
inspect: require('util').inspect
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
/**
|
|
@@ -56,40 +57,15 @@ class ParameterizedQueryError extends Error {
|
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
* It is called automatically when writing the object into the console.
|
|
65
|
-
*
|
|
66
|
-
* @param {number} [level=0]
|
|
67
|
-
* Nested output level, to provide visual offset.
|
|
68
|
-
*
|
|
69
|
-
* @returns {string}
|
|
70
|
-
*/
|
|
71
|
-
ParameterizedQueryError.prototype.toString = function (level) {
|
|
72
|
-
level = level > 0 ? parseInt(level) : 0;
|
|
73
|
-
const gap0 = npm.utils.messageGap(level),
|
|
74
|
-
gap1 = npm.utils.messageGap(level + 1),
|
|
75
|
-
gap2 = npm.utils.messageGap(level + 2),
|
|
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 + '}'
|
|
83
|
-
];
|
|
60
|
+
npm.utils.addInspection(ParameterizedQueryError, function () {
|
|
61
|
+
const obj = {
|
|
62
|
+
message: this.message,
|
|
63
|
+
result: this.result
|
|
64
|
+
};
|
|
84
65
|
if (this.error) {
|
|
85
|
-
|
|
66
|
+
obj.error = this.error;
|
|
86
67
|
}
|
|
87
|
-
|
|
88
|
-
return lines.join(npm.os.EOL);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
npm.utils.addInspection(ParameterizedQueryError, function () {
|
|
92
|
-
return this.toString();
|
|
68
|
+
return 'ParameterizedQueryError ' + npm.inspect(obj, {breakLength: 100, depth: 5, colors: true});
|
|
93
69
|
});
|
|
94
70
|
|
|
95
71
|
module.exports = {ParameterizedQueryError};
|
|
@@ -11,7 +11,8 @@ const {QueryFileError} = require('./query-file-error');
|
|
|
11
11
|
|
|
12
12
|
const npm = {
|
|
13
13
|
os: require('os'),
|
|
14
|
-
utils: require('../utils')
|
|
14
|
+
utils: require('../utils'),
|
|
15
|
+
inspect: require('util').inspect
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
/**
|
|
@@ -56,41 +57,15 @@ class PreparedStatementError extends Error {
|
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
* It is called automatically when writing the object into the console.
|
|
65
|
-
*
|
|
66
|
-
* @param {number} [level=0]
|
|
67
|
-
* Nested output level, to provide visual offset.
|
|
68
|
-
*
|
|
69
|
-
* @returns {string}
|
|
70
|
-
*/
|
|
71
|
-
PreparedStatementError.prototype.toString = function (level) {
|
|
72
|
-
level = level > 0 ? parseInt(level) : 0;
|
|
73
|
-
const gap0 = npm.utils.messageGap(level),
|
|
74
|
-
gap1 = npm.utils.messageGap(level + 1),
|
|
75
|
-
gap2 = npm.utils.messageGap(level + 2),
|
|
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 + '}'
|
|
84
|
-
];
|
|
60
|
+
npm.utils.addInspection(PreparedStatementError, function () {
|
|
61
|
+
const obj = {
|
|
62
|
+
message: this.message,
|
|
63
|
+
result: this.result
|
|
64
|
+
};
|
|
85
65
|
if (this.error) {
|
|
86
|
-
|
|
66
|
+
obj.error = this.error;
|
|
87
67
|
}
|
|
88
|
-
|
|
89
|
-
return lines.join(npm.os.EOL);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
npm.utils.addInspection(PreparedStatementError, function () {
|
|
93
|
-
return this.toString();
|
|
68
|
+
return 'PreparedStatementError ' + npm.inspect(obj, {breakLength: 100, depth: 5, colors: true});
|
|
94
69
|
});
|
|
95
70
|
|
|
96
71
|
module.exports = {PreparedStatementError};
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
const npm = {
|
|
11
11
|
os: require('os'),
|
|
12
12
|
utils: require('../utils'),
|
|
13
|
-
minify: require('pg-minify')
|
|
13
|
+
minify: require('pg-minify'),
|
|
14
|
+
inspect: require('util').inspect
|
|
14
15
|
};
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -59,37 +60,16 @@ class QueryFileError extends Error {
|
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
*
|
|
69
|
-
* @param {number} [level=0]
|
|
70
|
-
* Nested output level, to provide visual offset.
|
|
71
|
-
*
|
|
72
|
-
* @returns {string}
|
|
73
|
-
*/
|
|
74
|
-
QueryFileError.prototype.toString = function (level) {
|
|
75
|
-
level = level > 0 ? parseInt(level) : 0;
|
|
76
|
-
const gap0 = npm.utils.messageGap(level),
|
|
77
|
-
gap1 = npm.utils.messageGap(level + 1),
|
|
78
|
-
lines = [
|
|
79
|
-
'QueryFileError {',
|
|
80
|
-
gap1 + 'message: "' + this.message + '"',
|
|
81
|
-
gap1 + 'options: ' + npm.utils.toJson(this.options),
|
|
82
|
-
gap1 + 'file: "' + this.file + '"'
|
|
83
|
-
];
|
|
63
|
+
npm.utils.addInspection(QueryFileError, function () {
|
|
64
|
+
const obj = {
|
|
65
|
+
message: this.message,
|
|
66
|
+
file: this.file,
|
|
67
|
+
options: this.options
|
|
68
|
+
};
|
|
84
69
|
if (this.error) {
|
|
85
|
-
|
|
70
|
+
obj.error = this.error;
|
|
86
71
|
}
|
|
87
|
-
|
|
88
|
-
return lines.join(npm.os.EOL);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
npm.utils.addInspection(QueryFileError, function () {
|
|
92
|
-
return this.toString();
|
|
72
|
+
return 'QueryFileError ' + npm.inspect(obj, {breakLength: 100, depth: 5, colors: true});
|
|
93
73
|
});
|
|
94
74
|
|
|
95
75
|
module.exports = {QueryFileError};
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
const npm = {
|
|
11
11
|
os: require('os'),
|
|
12
12
|
utils: require('../utils'),
|
|
13
|
-
text: require('../text')
|
|
13
|
+
text: require('../text'),
|
|
14
|
+
inspect: require('util').inspect
|
|
14
15
|
};
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -102,7 +103,7 @@ const errorMessages = [
|
|
|
102
103
|
* error(err, e) {
|
|
103
104
|
* if (err instanceof QueryResultError) {
|
|
104
105
|
* // A query returned unexpected number of records, and thus rejected;
|
|
105
|
-
*
|
|
106
|
+
*
|
|
106
107
|
* // we can check the error code, if we want specifics:
|
|
107
108
|
* if(err.code === qrec.noData) {
|
|
108
109
|
* // expected some data, but received none;
|
|
@@ -112,7 +113,7 @@ const errorMessages = [
|
|
|
112
113
|
* // you will get a nicely formatted output.
|
|
113
114
|
*
|
|
114
115
|
* console.log(err);
|
|
115
|
-
*
|
|
116
|
+
*
|
|
116
117
|
* // See also: err, e.query, e.params, etc.
|
|
117
118
|
* }
|
|
118
119
|
* }
|
|
@@ -137,38 +138,17 @@ class QueryResultError extends Error {
|
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
140
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
* @param {number} [level=0]
|
|
148
|
-
* Nested output level, to provide visual offset.
|
|
149
|
-
*
|
|
150
|
-
* @returns {string}
|
|
151
|
-
*/
|
|
152
|
-
QueryResultError.prototype.toString = function (level) {
|
|
153
|
-
level = level > 0 ? parseInt(level) : 0;
|
|
154
|
-
const gap0 = npm.utils.messageGap(level),
|
|
155
|
-
gap1 = npm.utils.messageGap(level + 1),
|
|
156
|
-
lines = [
|
|
157
|
-
'QueryResultError {',
|
|
158
|
-
gap1 + 'code: queryResultErrorCode.' + errorMessages[this.code].name,
|
|
159
|
-
gap1 + 'message: "' + this.message + '"',
|
|
160
|
-
gap1 + 'received: ' + this.received,
|
|
161
|
-
gap1 + 'query: ' + (typeof this.query === 'string' ? '"' + this.query + '"' : npm.utils.toJson(this.query))
|
|
162
|
-
];
|
|
141
|
+
npm.utils.addInspection(QueryResultError, function () {
|
|
142
|
+
const obj = {
|
|
143
|
+
code: 'queryResultErrorCode.' + errorMessages[this.code].name,
|
|
144
|
+
message: this.message,
|
|
145
|
+
received: this.received,
|
|
146
|
+
query: typeof this.query === 'string' ? this.query : npm.utils.toJson(this.query)
|
|
147
|
+
};
|
|
163
148
|
if (this.values !== undefined) {
|
|
164
|
-
|
|
149
|
+
obj.values = this.values;
|
|
165
150
|
}
|
|
166
|
-
|
|
167
|
-
return lines.join(npm.os.EOL);
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
npm.utils.addInspection(QueryResultError, function () {
|
|
171
|
-
return this.toString();
|
|
151
|
+
return 'QueryResultError ' + npm.inspect(obj, {breakLength: 100, depth: 5, colors: true});
|
|
172
152
|
});
|
|
173
153
|
|
|
174
154
|
module.exports = {
|
|
@@ -428,7 +428,7 @@ ColumnSet.prototype.assignColumns = function (options) {
|
|
|
428
428
|
* @description
|
|
429
429
|
* Creates a new {@link helpers.ColumnSet ColumnSet}, by joining the two sets of columns.
|
|
430
430
|
*
|
|
431
|
-
* If the two sets contain a column with the same `name` (case-sensitive), an error is thrown (unless `
|
|
431
|
+
* If the two sets contain a column with the same `name` (case-sensitive), an error is thrown (unless `options.skip` is set to `true`).
|
|
432
432
|
*
|
|
433
433
|
* @param {helpers.Column|helpers.ColumnSet|array} columns
|
|
434
434
|
* Columns to be appended, of the same type as parameter `columns` during {@link helpers.ColumnSet ColumnSet} construction, except:
|
|
@@ -611,43 +611,4 @@ function colDesc(column, source) {
|
|
|
611
611
|
return a;
|
|
612
612
|
}
|
|
613
613
|
|
|
614
|
-
/**
|
|
615
|
-
* @method helpers.ColumnSet#toString
|
|
616
|
-
* @description
|
|
617
|
-
* Creates a well-formatted multi-line string that represents the object.
|
|
618
|
-
*
|
|
619
|
-
* It is called automatically when writing the object into the console.
|
|
620
|
-
*
|
|
621
|
-
* @param {number} [level=0]
|
|
622
|
-
* Nested output level, to provide visual offset.
|
|
623
|
-
*
|
|
624
|
-
* @returns {string}
|
|
625
|
-
*/
|
|
626
|
-
ColumnSet.prototype.toString = function (level) {
|
|
627
|
-
level = level > 0 ? parseInt(level) : 0;
|
|
628
|
-
const gap0 = npm.utils.messageGap(level),
|
|
629
|
-
gap1 = npm.utils.messageGap(level + 1),
|
|
630
|
-
lines = [
|
|
631
|
-
'ColumnSet {'
|
|
632
|
-
];
|
|
633
|
-
if (this.table) {
|
|
634
|
-
lines.push(gap1 + 'table: ' + this.table);
|
|
635
|
-
}
|
|
636
|
-
if (this.columns.length) {
|
|
637
|
-
lines.push(gap1 + 'columns: [');
|
|
638
|
-
this.columns.forEach(c => {
|
|
639
|
-
lines.push(c.toString(2));
|
|
640
|
-
});
|
|
641
|
-
lines.push(gap1 + ']');
|
|
642
|
-
} else {
|
|
643
|
-
lines.push(gap1 + 'columns: []');
|
|
644
|
-
}
|
|
645
|
-
lines.push(gap0 + '}');
|
|
646
|
-
return lines.join(npm.os.EOL);
|
|
647
|
-
};
|
|
648
|
-
|
|
649
|
-
npm.utils.addInspection(ColumnSet, function () {
|
|
650
|
-
return this.toString();
|
|
651
|
-
});
|
|
652
|
-
|
|
653
614
|
module.exports = {ColumnSet};
|
package/lib/helpers/column.js
CHANGED
|
@@ -289,55 +289,6 @@ function isValidVariable(name) {
|
|
|
289
289
|
return !!m && m[0] === name;
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
-
/**
|
|
293
|
-
* @method helpers.Column#toString
|
|
294
|
-
* @description
|
|
295
|
-
* Creates a well-formatted multi-line string that represents the object.
|
|
296
|
-
*
|
|
297
|
-
* It is called automatically when writing the object into the console.
|
|
298
|
-
*
|
|
299
|
-
* @param {number} [level=0]
|
|
300
|
-
* Nested output level, to provide visual offset.
|
|
301
|
-
*
|
|
302
|
-
* @returns {string}
|
|
303
|
-
*/
|
|
304
|
-
Column.prototype.toString = function (level) {
|
|
305
|
-
level = level > 0 ? parseInt(level) : 0;
|
|
306
|
-
const gap0 = npm.utils.messageGap(level),
|
|
307
|
-
gap1 = npm.utils.messageGap(level + 1),
|
|
308
|
-
lines = [
|
|
309
|
-
gap0 + 'Column {',
|
|
310
|
-
gap1 + 'name: ' + npm.utils.toJson(this.name)
|
|
311
|
-
];
|
|
312
|
-
if ('prop' in this) {
|
|
313
|
-
lines.push(gap1 + 'prop: ' + npm.utils.toJson(this.prop));
|
|
314
|
-
}
|
|
315
|
-
if ('mod' in this) {
|
|
316
|
-
lines.push(gap1 + 'mod: ' + npm.utils.toJson(this.mod));
|
|
317
|
-
}
|
|
318
|
-
if ('cast' in this) {
|
|
319
|
-
lines.push(gap1 + 'cast: ' + npm.utils.toJson(this.cast));
|
|
320
|
-
}
|
|
321
|
-
if ('cnd' in this) {
|
|
322
|
-
lines.push(gap1 + 'cnd: ' + npm.utils.toJson(this.cnd));
|
|
323
|
-
}
|
|
324
|
-
if ('def' in this) {
|
|
325
|
-
lines.push(gap1 + 'def: ' + npm.utils.toJson(this.def));
|
|
326
|
-
}
|
|
327
|
-
if ('init' in this) {
|
|
328
|
-
lines.push(gap1 + 'init: [Function]');
|
|
329
|
-
}
|
|
330
|
-
if ('skip' in this) {
|
|
331
|
-
lines.push(gap1 + 'skip: [Function]');
|
|
332
|
-
}
|
|
333
|
-
lines.push(gap0 + '}');
|
|
334
|
-
return lines.join(npm.os.EOL);
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
npm.utils.addInspection(Column, function () {
|
|
338
|
-
return this.toString();
|
|
339
|
-
});
|
|
340
|
-
|
|
341
292
|
/**
|
|
342
293
|
* @typedef helpers.ColumnConfig
|
|
343
294
|
* @description
|
|
@@ -114,18 +114,12 @@ TableName.prototype[npm.format.ctf.rawType] = true; // use as pre-formatted
|
|
|
114
114
|
* @description
|
|
115
115
|
* Creates a well-formatted string that represents the object.
|
|
116
116
|
*
|
|
117
|
-
* It is called automatically when writing the object into the console.
|
|
118
|
-
*
|
|
119
117
|
* @returns {string}
|
|
120
118
|
*/
|
|
121
119
|
TableName.prototype.toString = function () {
|
|
122
120
|
return this.name;
|
|
123
121
|
};
|
|
124
122
|
|
|
125
|
-
npm.utils.addInspection(TableName, function () {
|
|
126
|
-
return this.toString();
|
|
127
|
-
});
|
|
128
|
-
|
|
129
123
|
/**
|
|
130
124
|
* @interface Table
|
|
131
125
|
* @description
|
package/lib/query-file.js
CHANGED
|
@@ -18,7 +18,8 @@ const npm = {
|
|
|
18
18
|
path: require('path'),
|
|
19
19
|
minify: require('pg-minify'),
|
|
20
20
|
utils: require('./utils'),
|
|
21
|
-
formatting: require('./formatting')
|
|
21
|
+
formatting: require('./formatting'),
|
|
22
|
+
inspect: require('util').inspect
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
const file$query = Symbol('QueryFile.query');
|
|
@@ -312,38 +313,18 @@ QueryFile.prototype[npm.formatting.as.ctf.toPostgres] = function (self) {
|
|
|
312
313
|
|
|
313
314
|
QueryFile.prototype[npm.formatting.as.ctf.rawType] = true; // use as pre-formatted
|
|
314
315
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
*
|
|
322
|
-
* @param {number} [level=0]
|
|
323
|
-
* Nested output level, to provide visual offset.
|
|
324
|
-
*
|
|
325
|
-
* @returns {string}
|
|
326
|
-
*/
|
|
327
|
-
QueryFile.prototype.toString = function (level) {
|
|
328
|
-
level = level > 0 ? parseInt(level) : 0;
|
|
329
|
-
const gap = npm.utils.messageGap(level + 1);
|
|
330
|
-
const lines = [
|
|
331
|
-
'QueryFile {'
|
|
332
|
-
];
|
|
316
|
+
npm.utils.addInspection(QueryFile, function () {
|
|
317
|
+
const s = 'QueryFile ';
|
|
318
|
+
const obj = {
|
|
319
|
+
file: this.file,
|
|
320
|
+
options: this.options
|
|
321
|
+
};
|
|
333
322
|
this.prepare();
|
|
334
|
-
lines.push(gap + 'file: "' + this.file + '"');
|
|
335
|
-
lines.push(gap + 'options: ' + npm.utils.toJson(this.options));
|
|
336
323
|
if (this.error) {
|
|
337
|
-
|
|
338
|
-
} else {
|
|
339
|
-
lines.push(gap + 'query: "' + this[QueryFile.$query] + '"');
|
|
324
|
+
obj.error = this.error;
|
|
340
325
|
}
|
|
341
|
-
|
|
342
|
-
return
|
|
343
|
-
};
|
|
344
|
-
|
|
345
|
-
npm.utils.addInspection(QueryFile, function () {
|
|
346
|
-
return this.toString();
|
|
326
|
+
obj.query = this[QueryFile.$query];
|
|
327
|
+
return s + npm.inspect(obj, {breakLength: 100, depth: 5, colors: true});
|
|
347
328
|
});
|
|
348
329
|
|
|
349
330
|
module.exports = {QueryFile};
|
package/lib/tx-mode.js
CHANGED
|
@@ -8,9 +8,13 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
const {InnerState} = require('./inner-state');
|
|
11
|
-
const {addInspection} = require('./utils');
|
|
12
11
|
const {assert} = require('./assert');
|
|
13
12
|
|
|
13
|
+
const npm = {
|
|
14
|
+
addInspection: require('./utils').addInspection,
|
|
15
|
+
inspect: require('util').inspect
|
|
16
|
+
};
|
|
17
|
+
|
|
14
18
|
/**
|
|
15
19
|
* @enum {number}
|
|
16
20
|
* @alias txMode.isolationLevel
|
|
@@ -22,7 +26,7 @@ const {assert} = require('./assert');
|
|
|
22
26
|
* @see $[Transaction Isolation]
|
|
23
27
|
*/
|
|
24
28
|
const isolationLevel = {
|
|
25
|
-
/** Isolation level
|
|
29
|
+
/** Isolation level isn't specified. */
|
|
26
30
|
none: 0,
|
|
27
31
|
|
|
28
32
|
/** `ISOLATION LEVEL SERIALIZABLE` */
|
|
@@ -161,8 +165,9 @@ class TransactionMode extends InnerState {
|
|
|
161
165
|
}
|
|
162
166
|
}
|
|
163
167
|
|
|
164
|
-
addInspection(TransactionMode, function () {
|
|
165
|
-
|
|
168
|
+
npm.addInspection(TransactionMode, function () {
|
|
169
|
+
const obj = {SQL: this.begin(true)};
|
|
170
|
+
return 'TransactionMode ' + npm.inspect(obj, {breakLength: 100, depth: 5, colors: true});
|
|
166
171
|
});
|
|
167
172
|
|
|
168
173
|
/**
|
|
@@ -187,4 +192,3 @@ module.exports = {
|
|
|
187
192
|
isolationLevel,
|
|
188
193
|
TransactionMode
|
|
189
194
|
};
|
|
190
|
-
|
|
@@ -14,7 +14,8 @@ const {assert} = require('../assert');
|
|
|
14
14
|
|
|
15
15
|
const npm = {
|
|
16
16
|
EOL: require('os').EOL,
|
|
17
|
-
utils: require('../utils')
|
|
17
|
+
utils: require('../utils'),
|
|
18
|
+
inspect: require('util').inspect
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -162,43 +163,26 @@ ParameterizedQuery.prototype.parse = function () {
|
|
|
162
163
|
return _i.target;
|
|
163
164
|
};
|
|
164
165
|
|
|
165
|
-
|
|
166
|
-
* @method ParameterizedQuery#toString
|
|
167
|
-
* @description
|
|
168
|
-
* Creates a well-formatted multi-line string that represents the object's current state.
|
|
169
|
-
*
|
|
170
|
-
* It is called automatically when writing the object into the console.
|
|
171
|
-
*
|
|
172
|
-
* @param {number} [level=0]
|
|
173
|
-
* Nested output level, to provide visual offset.
|
|
174
|
-
*
|
|
175
|
-
* @returns {string}
|
|
176
|
-
*/
|
|
177
|
-
ParameterizedQuery.prototype.toString = function (level) {
|
|
178
|
-
level = level > 0 ? parseInt(level) : 0;
|
|
179
|
-
const gap = npm.utils.messageGap(level + 1);
|
|
166
|
+
npm.utils.addInspection(ParameterizedQuery, function () {
|
|
180
167
|
const pq = this.parse();
|
|
181
|
-
const
|
|
182
|
-
'ParameterizedQuery {'
|
|
183
|
-
];
|
|
168
|
+
const obj = {};
|
|
184
169
|
if (npm.utils.isText(pq.text)) {
|
|
185
|
-
|
|
170
|
+
obj.text = pq.text;
|
|
186
171
|
}
|
|
187
172
|
if (this.values !== undefined) {
|
|
188
|
-
|
|
173
|
+
obj.values = this.values;
|
|
189
174
|
}
|
|
190
175
|
if (this.binary !== undefined) {
|
|
191
|
-
|
|
176
|
+
obj.binary = this.binary;
|
|
192
177
|
}
|
|
193
178
|
if (this.rowMode !== undefined) {
|
|
194
|
-
|
|
179
|
+
obj.rowMode = this.rowMode;
|
|
195
180
|
}
|
|
196
181
|
if (this.error !== undefined) {
|
|
197
|
-
|
|
182
|
+
obj.error = this.error.message;
|
|
198
183
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
};
|
|
184
|
+
return 'ParameterizedQuery ' + npm.inspect(obj, {breakLength: 100, depth: 5, colors: true});
|
|
185
|
+
});
|
|
202
186
|
|
|
203
187
|
module.exports = {ParameterizedQuery};
|
|
204
188
|
|
|
@@ -14,7 +14,8 @@ const {assert} = require('../assert');
|
|
|
14
14
|
|
|
15
15
|
const npm = {
|
|
16
16
|
EOL: require('os').EOL,
|
|
17
|
-
utils: require('../utils')
|
|
17
|
+
utils: require('../utils'),
|
|
18
|
+
inspect: require('util').inspect
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -206,47 +207,31 @@ PreparedStatement.prototype.parse = function () {
|
|
|
206
207
|
return _i.target;
|
|
207
208
|
};
|
|
208
209
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
* @param {number} [level=0]
|
|
217
|
-
* Nested output level, to provide visual offset.
|
|
218
|
-
*
|
|
219
|
-
* @returns {string}
|
|
220
|
-
*/
|
|
221
|
-
PreparedStatement.prototype.toString = function (level) {
|
|
222
|
-
level = level > 0 ? parseInt(level) : 0;
|
|
223
|
-
const gap = npm.utils.messageGap(level + 1);
|
|
224
|
-
const ps = this.parse();
|
|
225
|
-
const lines = [
|
|
226
|
-
'PreparedStatement {',
|
|
227
|
-
gap + 'name: ' + npm.utils.toJson(this.name)
|
|
228
|
-
];
|
|
229
|
-
if (npm.utils.isText(ps.text)) {
|
|
230
|
-
lines.push(gap + 'text: "' + ps.text + '"');
|
|
210
|
+
npm.utils.addInspection(PreparedStatement, function () {
|
|
211
|
+
const pq = this.parse();
|
|
212
|
+
const obj = {
|
|
213
|
+
name: this.name
|
|
214
|
+
};
|
|
215
|
+
if (npm.utils.isText(pq.text)) {
|
|
216
|
+
obj.text = pq.text;
|
|
231
217
|
}
|
|
232
218
|
if (this.values !== undefined) {
|
|
233
|
-
|
|
219
|
+
obj.values = this.values;
|
|
234
220
|
}
|
|
235
221
|
if (this.binary !== undefined) {
|
|
236
|
-
|
|
222
|
+
obj.binary = this.binary;
|
|
237
223
|
}
|
|
238
224
|
if (this.rowMode !== undefined) {
|
|
239
|
-
|
|
225
|
+
obj.rowMode = this.rowMode;
|
|
240
226
|
}
|
|
241
227
|
if (this.rows !== undefined) {
|
|
242
|
-
|
|
228
|
+
obj.rows = this.rows;
|
|
243
229
|
}
|
|
244
|
-
if (this.error) {
|
|
245
|
-
|
|
230
|
+
if (this.error !== undefined) {
|
|
231
|
+
obj.error = this.error.message;
|
|
246
232
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
};
|
|
233
|
+
return 'PreparedStatement ' + npm.inspect(obj, {breakLength: 100, depth: 5, colors: true});
|
|
234
|
+
});
|
|
250
235
|
|
|
251
236
|
module.exports = {PreparedStatement};
|
|
252
237
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const {InnerState} = require('../inner-state');
|
|
2
|
-
const {addInspection} = require('../utils');
|
|
3
2
|
const utils = require('../utils');
|
|
4
3
|
|
|
5
4
|
/**
|
|
@@ -90,8 +89,4 @@ function setValues(v) {
|
|
|
90
89
|
}
|
|
91
90
|
}
|
|
92
91
|
|
|
93
|
-
addInspection(ServerFormatting, function () {
|
|
94
|
-
return this.toString();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
92
|
module.exports = {ServerFormatting};
|
package/lib/utils/index.js
CHANGED
|
@@ -73,12 +73,6 @@ function getSafeConnection(cn) {
|
|
|
73
73
|
return maskPassword(cn);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
///////////////////////////////////////////
|
|
77
|
-
// Returns a space gap for console output;
|
|
78
|
-
function messageGap(level) {
|
|
79
|
-
return ' '.repeat(level * 4);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
76
|
/////////////////////////////////////////
|
|
83
77
|
// Provides platform-neutral inheritance;
|
|
84
78
|
function inherits(child, parent) {
|
|
@@ -193,7 +187,6 @@ const exp = {
|
|
|
193
187
|
addReadProp,
|
|
194
188
|
addReadProperties,
|
|
195
189
|
getSafeConnection,
|
|
196
|
-
messageGap,
|
|
197
190
|
inherits,
|
|
198
191
|
isConnectivityError
|
|
199
192
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pg-promise",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.6.1",
|
|
4
4
|
"description": "PostgreSQL interface for Node.js",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "typescript/pg-promise.d.ts",
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
"pg-query-stream": "4.12.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@eslint/js": "
|
|
54
|
-
"@types/node": "25.
|
|
53
|
+
"@eslint/js": "10.0.1",
|
|
54
|
+
"@types/node": "25.2.3",
|
|
55
55
|
"coveralls": "3.1.1",
|
|
56
|
-
"cspell": "9.6.
|
|
57
|
-
"eslint": "
|
|
58
|
-
"globals": "17.
|
|
56
|
+
"cspell": "9.6.4",
|
|
57
|
+
"eslint": "10.0.0",
|
|
58
|
+
"globals": "17.3.0",
|
|
59
59
|
"jasmine-node": "3.0.0",
|
|
60
60
|
"jsdoc": "4.0.5",
|
|
61
61
|
"JSONStream": "1.3.5",
|