postgrejs 2.15.2 → 2.16.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/CHANGELOG.md +21 -0
- package/esm/connection/bind-param.js +5 -1
- package/esm/connection/connection.js +20 -16
- package/esm/connection/cursor.js +15 -10
- package/esm/connection/intl-connection.js +46 -41
- package/esm/connection/pool.js +32 -28
- package/esm/connection/portal.js +31 -27
- package/esm/connection/prepared-statement.js +35 -31
- package/esm/constants.js +125 -122
- package/esm/data-type-map.js +75 -71
- package/esm/data-types/bool-type.js +10 -7
- package/esm/data-types/box-type.js +10 -7
- package/esm/data-types/bytea-type.js +13 -9
- package/esm/data-types/char-type.js +10 -7
- package/esm/data-types/circle-type.js +10 -7
- package/esm/data-types/date-type.js +15 -12
- package/esm/data-types/float4-type.js +10 -7
- package/esm/data-types/float8-type.js +10 -7
- package/esm/data-types/int2-type.js +13 -10
- package/esm/data-types/int2-vector-type.js +16 -13
- package/esm/data-types/int4-type.js +13 -10
- package/esm/data-types/int8-type.js +12 -9
- package/esm/data-types/json-type.js +12 -9
- package/esm/data-types/jsonb-type.js +14 -11
- package/esm/data-types/lseg-type.js +10 -7
- package/esm/data-types/numeric-type.js +12 -8
- package/esm/data-types/oid-type.js +18 -15
- package/esm/data-types/point-type.js +10 -7
- package/esm/data-types/time-type.js +16 -13
- package/esm/data-types/timestamp-type.js +15 -12
- package/esm/data-types/timestamptz-type.js +15 -12
- package/esm/data-types/uuid-type.js +10 -7
- package/esm/data-types/varchar-type.js +10 -7
- package/esm/index.js +28 -25
- package/esm/interfaces/command-result.js +2 -1
- package/esm/interfaces/data-mapping-options.js +2 -1
- package/esm/interfaces/data-type.js +2 -1
- package/esm/interfaces/database-connection-params.js +2 -1
- package/esm/interfaces/field-info.js +2 -1
- package/esm/interfaces/query-options.js +2 -1
- package/esm/interfaces/query-result.js +2 -1
- package/esm/interfaces/script-execute-options.js +2 -1
- package/esm/interfaces/script-result.js +2 -1
- package/esm/interfaces/statement-prepare-options.js +2 -1
- package/esm/protocol/backend.js +28 -24
- package/esm/protocol/buffer-reader.js +5 -1
- package/esm/protocol/database-error.js +5 -1
- package/esm/protocol/frontend.js +31 -27
- package/esm/protocol/pg-socket.js +53 -48
- package/esm/protocol/protocol.js +5 -2
- package/esm/protocol/sasl.js +11 -7
- package/esm/protocol/smart-buffer.js +10 -5
- package/esm/safe-event-emitter.js +6 -2
- package/esm/types.js +2 -1
- package/esm/util/array-calculatedim.js +4 -1
- package/esm/util/bigint-methods.js +6 -2
- package/esm/util/config-from-env.js +8 -5
- package/esm/util/connection-config.js +13 -8
- package/esm/util/convert-row-to-object.js +4 -1
- package/esm/util/decode-binaryarray.js +6 -3
- package/esm/util/encode-binaryarray.js +8 -5
- package/esm/util/escape-literal.js +4 -1
- package/esm/util/fast-parseint.js +4 -1
- package/esm/util/get-parsers.js +11 -8
- package/esm/util/parse-array.js +4 -1
- package/esm/util/parse-datetime.js +8 -5
- package/esm/util/parse-row.js +4 -1
- package/esm/util/parse-time.js +12 -8
- package/esm/util/stringify-arrayliteral.js +6 -3
- package/esm/util/stringify-for-sql.js +12 -8
- package/esm/util/wrap-row-description.js +9 -6
- package/package.json +23 -16
- package/cjs/package.json +0 -3
- /package/{typings → types}/connection/bind-param.d.ts +0 -0
- /package/{typings → types}/connection/connection.d.ts +0 -0
- /package/{typings → types}/connection/cursor.d.ts +0 -0
- /package/{typings → types}/connection/intl-connection.d.ts +0 -0
- /package/{typings → types}/connection/pool.d.ts +0 -0
- /package/{typings → types}/connection/portal.d.ts +0 -0
- /package/{typings → types}/connection/prepared-statement.d.ts +0 -0
- /package/{typings → types}/constants.d.ts +0 -0
- /package/{typings → types}/data-type-map.d.ts +0 -0
- /package/{typings → types}/data-types/bool-type.d.ts +0 -0
- /package/{typings → types}/data-types/box-type.d.ts +0 -0
- /package/{typings → types}/data-types/bytea-type.d.ts +0 -0
- /package/{typings → types}/data-types/char-type.d.ts +0 -0
- /package/{typings → types}/data-types/circle-type.d.ts +0 -0
- /package/{typings → types}/data-types/date-type.d.ts +0 -0
- /package/{typings → types}/data-types/float4-type.d.ts +0 -0
- /package/{typings → types}/data-types/float8-type.d.ts +0 -0
- /package/{typings → types}/data-types/int2-type.d.ts +0 -0
- /package/{typings → types}/data-types/int2-vector-type.d.ts +0 -0
- /package/{typings → types}/data-types/int4-type.d.ts +0 -0
- /package/{typings → types}/data-types/int8-type.d.ts +0 -0
- /package/{typings → types}/data-types/json-type.d.ts +0 -0
- /package/{typings → types}/data-types/jsonb-type.d.ts +0 -0
- /package/{typings → types}/data-types/lseg-type.d.ts +0 -0
- /package/{typings → types}/data-types/numeric-type.d.ts +0 -0
- /package/{typings → types}/data-types/oid-type.d.ts +0 -0
- /package/{typings → types}/data-types/point-type.d.ts +0 -0
- /package/{typings → types}/data-types/time-type.d.ts +0 -0
- /package/{typings → types}/data-types/timestamp-type.d.ts +0 -0
- /package/{typings → types}/data-types/timestamptz-type.d.ts +0 -0
- /package/{typings → types}/data-types/uuid-type.d.ts +0 -0
- /package/{typings → types}/data-types/varchar-type.d.ts +0 -0
- /package/{typings → types}/index.d.ts +0 -0
- /package/{typings → types}/interfaces/command-result.d.ts +0 -0
- /package/{typings → types}/interfaces/data-mapping-options.d.ts +0 -0
- /package/{typings → types}/interfaces/data-type.d.ts +0 -0
- /package/{typings → types}/interfaces/database-connection-params.d.ts +0 -0
- /package/{typings → types}/interfaces/field-info.d.ts +0 -0
- /package/{typings → types}/interfaces/query-options.d.ts +0 -0
- /package/{typings → types}/interfaces/query-result.d.ts +0 -0
- /package/{typings → types}/interfaces/script-execute-options.d.ts +0 -0
- /package/{typings → types}/interfaces/script-result.d.ts +0 -0
- /package/{typings → types}/interfaces/statement-prepare-options.d.ts +0 -0
- /package/{typings → types}/protocol/backend.d.ts +0 -0
- /package/{typings → types}/protocol/buffer-reader.d.ts +0 -0
- /package/{typings → types}/protocol/database-error.d.ts +0 -0
- /package/{typings → types}/protocol/frontend.d.ts +0 -0
- /package/{typings → types}/protocol/pg-socket.d.ts +0 -0
- /package/{typings → types}/protocol/protocol.d.ts +0 -0
- /package/{typings → types}/protocol/sasl.d.ts +0 -0
- /package/{typings → types}/protocol/smart-buffer.d.ts +0 -0
- /package/{typings → types}/safe-event-emitter.d.ts +0 -0
- /package/{typings → types}/types.d.ts +0 -0
- /package/{typings → types}/util/array-calculatedim.d.ts +0 -0
- /package/{typings → types}/util/bigint-methods.d.ts +0 -0
- /package/{typings → types}/util/config-from-env.d.ts +0 -0
- /package/{typings → types}/util/connection-config.d.ts +0 -0
- /package/{typings → types}/util/convert-row-to-object.d.ts +0 -0
- /package/{typings → types}/util/decode-binaryarray.d.ts +0 -0
- /package/{typings → types}/util/encode-binaryarray.d.ts +0 -0
- /package/{typings → types}/util/escape-literal.d.ts +0 -0
- /package/{typings → types}/util/fast-parseint.d.ts +0 -0
- /package/{typings → types}/util/get-parsers.d.ts +0 -0
- /package/{typings → types}/util/parse-array.d.ts +0 -0
- /package/{typings → types}/util/parse-datetime.d.ts +0 -0
- /package/{typings → types}/util/parse-row.d.ts +0 -0
- /package/{typings → types}/util/parse-time.d.ts +0 -0
- /package/{typings → types}/util/stringify-arrayliteral.d.ts +0 -0
- /package/{typings → types}/util/stringify-for-sql.d.ts +0 -0
- /package/{typings → types}/util/wrap-row-description.d.ts +0 -0
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrayBoxType = exports.BoxType = void 0;
|
|
4
|
+
const constants_js_1 = require("../constants.js");
|
|
2
5
|
const BOX_PATTERN1 = /^\( *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *\)$/;
|
|
3
6
|
const BOX_PATTERN2 = /^\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\)$/;
|
|
4
7
|
const BOX_PATTERN3 = /^(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *, *(-?\d+\.?\d*)$/;
|
|
5
|
-
|
|
8
|
+
exports.BoxType = {
|
|
6
9
|
name: 'box',
|
|
7
|
-
oid: DataTypeOIDs.box,
|
|
10
|
+
oid: constants_js_1.DataTypeOIDs.box,
|
|
8
11
|
jsType: 'object',
|
|
9
12
|
arraySeparator: ';',
|
|
10
13
|
parseBinary(v) {
|
|
@@ -41,9 +44,9 @@ export const BoxType = {
|
|
|
41
44
|
typeof v.y2 === 'number');
|
|
42
45
|
},
|
|
43
46
|
};
|
|
44
|
-
|
|
45
|
-
...BoxType,
|
|
47
|
+
exports.ArrayBoxType = {
|
|
48
|
+
...exports.BoxType,
|
|
46
49
|
name: '_box',
|
|
47
|
-
oid: DataTypeOIDs._box,
|
|
48
|
-
elementsOID: DataTypeOIDs.box,
|
|
50
|
+
oid: constants_js_1.DataTypeOIDs._box,
|
|
51
|
+
elementsOID: constants_js_1.DataTypeOIDs.box,
|
|
49
52
|
};
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrayByteaType = exports.ByteaType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const postgres_bytea_1 = tslib_1.__importDefault(require("postgres-bytea"));
|
|
6
|
+
const constants_js_1 = require("../constants.js");
|
|
7
|
+
exports.ByteaType = {
|
|
4
8
|
name: 'bytea',
|
|
5
|
-
oid: DataTypeOIDs.bytea,
|
|
9
|
+
oid: constants_js_1.DataTypeOIDs.bytea,
|
|
6
10
|
jsType: 'Buffer',
|
|
7
11
|
parseBinary(v) {
|
|
8
12
|
return v;
|
|
@@ -10,14 +14,14 @@ export const ByteaType = {
|
|
|
10
14
|
encodeBinary(buf, v) {
|
|
11
15
|
buf.writeBuffer(v);
|
|
12
16
|
},
|
|
13
|
-
parseText:
|
|
17
|
+
parseText: postgres_bytea_1.default,
|
|
14
18
|
isType(v) {
|
|
15
19
|
return v instanceof Buffer;
|
|
16
20
|
},
|
|
17
21
|
};
|
|
18
|
-
|
|
19
|
-
...ByteaType,
|
|
22
|
+
exports.ArrayByteaType = {
|
|
23
|
+
...exports.ByteaType,
|
|
20
24
|
name: '_bytea',
|
|
21
|
-
oid: DataTypeOIDs._bytea,
|
|
22
|
-
elementsOID: DataTypeOIDs.bytea,
|
|
25
|
+
oid: constants_js_1.DataTypeOIDs._bytea,
|
|
26
|
+
elementsOID: constants_js_1.DataTypeOIDs.bytea,
|
|
23
27
|
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrayCharType = exports.CharType = void 0;
|
|
4
|
+
const constants_js_1 = require("../constants.js");
|
|
5
|
+
exports.CharType = {
|
|
3
6
|
name: 'char',
|
|
4
|
-
oid: DataTypeOIDs.char,
|
|
7
|
+
oid: constants_js_1.DataTypeOIDs.char,
|
|
5
8
|
jsType: 'string',
|
|
6
9
|
parseBinary(v) {
|
|
7
10
|
return v.toString('utf8');
|
|
@@ -16,9 +19,9 @@ export const CharType = {
|
|
|
16
19
|
return typeof v === 'string' && v.length === 1;
|
|
17
20
|
},
|
|
18
21
|
};
|
|
19
|
-
|
|
20
|
-
...CharType,
|
|
22
|
+
exports.ArrayCharType = {
|
|
23
|
+
...exports.CharType,
|
|
21
24
|
name: '_char',
|
|
22
|
-
oid: DataTypeOIDs._char,
|
|
23
|
-
elementsOID: DataTypeOIDs.char,
|
|
25
|
+
oid: constants_js_1.DataTypeOIDs._char,
|
|
26
|
+
elementsOID: constants_js_1.DataTypeOIDs.char,
|
|
24
27
|
};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrayCircleType = exports.CircleType = void 0;
|
|
4
|
+
const constants_js_1 = require("../constants.js");
|
|
2
5
|
const CIRCLE_PATTERN1 = /^< *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *(-?\d+\.?\d*) *>$/;
|
|
3
6
|
const CIRCLE_PATTERN2 = /^\( *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *(-?\d+\.?\d*) *\)$/;
|
|
4
7
|
const CIRCLE_PATTERN3 = /^\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *(-?\d+\.?\d*)$/;
|
|
5
8
|
const CIRCLE_PATTERN4 = /^(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *, *(-?\d+\.?\d*)$/;
|
|
6
|
-
|
|
9
|
+
exports.CircleType = {
|
|
7
10
|
name: 'circle',
|
|
8
|
-
oid: DataTypeOIDs.circle,
|
|
11
|
+
oid: constants_js_1.DataTypeOIDs.circle,
|
|
9
12
|
jsType: 'object',
|
|
10
13
|
parseBinary(v) {
|
|
11
14
|
return {
|
|
@@ -37,9 +40,9 @@ export const CircleType = {
|
|
|
37
40
|
typeof v.r === 'number');
|
|
38
41
|
},
|
|
39
42
|
};
|
|
40
|
-
|
|
41
|
-
...CircleType,
|
|
43
|
+
exports.ArrayCircleType = {
|
|
44
|
+
...exports.CircleType,
|
|
42
45
|
name: '_circle',
|
|
43
|
-
oid: DataTypeOIDs._circle,
|
|
44
|
-
elementsOID: DataTypeOIDs.circle,
|
|
46
|
+
oid: constants_js_1.DataTypeOIDs._circle,
|
|
47
|
+
elementsOID: constants_js_1.DataTypeOIDs.circle,
|
|
45
48
|
};
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrayDateType = exports.DateType = void 0;
|
|
4
|
+
const constants_js_1 = require("../constants.js");
|
|
5
|
+
const parse_datetime_js_1 = require("../util/parse-datetime.js");
|
|
3
6
|
const timeShift = 946684800000;
|
|
4
|
-
|
|
7
|
+
exports.DateType = {
|
|
5
8
|
name: 'date',
|
|
6
|
-
oid: DataTypeOIDs.date,
|
|
9
|
+
oid: constants_js_1.DataTypeOIDs.date,
|
|
7
10
|
jsType: 'Date',
|
|
8
11
|
parseBinary(v, options) {
|
|
9
|
-
const fetchAsString = options.fetchAsString && options.fetchAsString.includes(DataTypeOIDs.date);
|
|
12
|
+
const fetchAsString = options.fetchAsString && options.fetchAsString.includes(constants_js_1.DataTypeOIDs.date);
|
|
10
13
|
const t = v.readInt32BE();
|
|
11
14
|
if (t === 0x7fffffff)
|
|
12
15
|
return fetchAsString ? 'infinity' : Infinity;
|
|
@@ -20,7 +23,7 @@ export const DateType = {
|
|
|
20
23
|
},
|
|
21
24
|
encodeBinary(buf, v, options) {
|
|
22
25
|
if (typeof v === 'string')
|
|
23
|
-
v = parseDateTime(v, false, false, options.utcDates);
|
|
26
|
+
v = (0, parse_datetime_js_1.parseDateTime)(v, false, false, options.utcDates);
|
|
24
27
|
if (v === Infinity) {
|
|
25
28
|
buf.writeInt32BE(0x7fffffff);
|
|
26
29
|
return;
|
|
@@ -37,10 +40,10 @@ export const DateType = {
|
|
|
37
40
|
buf.writeInt32BE(t);
|
|
38
41
|
},
|
|
39
42
|
parseText(v, options) {
|
|
40
|
-
const fetchAsString = options.fetchAsString && options.fetchAsString.includes(DataTypeOIDs.date);
|
|
43
|
+
const fetchAsString = options.fetchAsString && options.fetchAsString.includes(constants_js_1.DataTypeOIDs.date);
|
|
41
44
|
if (fetchAsString)
|
|
42
45
|
return v;
|
|
43
|
-
return parseDateTime(v, false, false, options.utcDates);
|
|
46
|
+
return (0, parse_datetime_js_1.parseDateTime)(v, false, false, options.utcDates);
|
|
44
47
|
},
|
|
45
48
|
isType(v) {
|
|
46
49
|
return (v instanceof Date &&
|
|
@@ -56,9 +59,9 @@ function padZero(v) {
|
|
|
56
59
|
function dateToDateString(d) {
|
|
57
60
|
return d.getFullYear() + '-' + padZero(d.getMonth() + 1) + '-' + padZero(d.getDate());
|
|
58
61
|
}
|
|
59
|
-
|
|
60
|
-
...DateType,
|
|
62
|
+
exports.ArrayDateType = {
|
|
63
|
+
...exports.DateType,
|
|
61
64
|
name: '_date',
|
|
62
|
-
oid: DataTypeOIDs._date,
|
|
63
|
-
elementsOID: DataTypeOIDs.date,
|
|
65
|
+
oid: constants_js_1.DataTypeOIDs._date,
|
|
66
|
+
elementsOID: constants_js_1.DataTypeOIDs.date,
|
|
64
67
|
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrayFloat4Type = exports.Float4Type = void 0;
|
|
4
|
+
const constants_js_1 = require("../constants.js");
|
|
5
|
+
exports.Float4Type = {
|
|
3
6
|
name: 'float4',
|
|
4
|
-
oid: DataTypeOIDs.float4,
|
|
7
|
+
oid: constants_js_1.DataTypeOIDs.float4,
|
|
5
8
|
jsType: 'number',
|
|
6
9
|
parseBinary(v) {
|
|
7
10
|
return Math.round((v.readFloatBE(0) + Number.EPSILON) * 100) / 100;
|
|
@@ -14,9 +17,9 @@ export const Float4Type = {
|
|
|
14
17
|
return typeof v === 'number';
|
|
15
18
|
},
|
|
16
19
|
};
|
|
17
|
-
|
|
18
|
-
...Float4Type,
|
|
20
|
+
exports.ArrayFloat4Type = {
|
|
21
|
+
...exports.Float4Type,
|
|
19
22
|
name: '_float4',
|
|
20
|
-
oid: DataTypeOIDs._float4,
|
|
21
|
-
elementsOID: DataTypeOIDs.float4,
|
|
23
|
+
oid: constants_js_1.DataTypeOIDs._float4,
|
|
24
|
+
elementsOID: constants_js_1.DataTypeOIDs.float4,
|
|
22
25
|
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrayFloat8Type = exports.Float8Type = void 0;
|
|
4
|
+
const constants_js_1 = require("../constants.js");
|
|
5
|
+
exports.Float8Type = {
|
|
3
6
|
name: 'float8',
|
|
4
|
-
oid: DataTypeOIDs.float8,
|
|
7
|
+
oid: constants_js_1.DataTypeOIDs.float8,
|
|
5
8
|
jsType: 'number',
|
|
6
9
|
parseBinary(v) {
|
|
7
10
|
return v.readDoubleBE(0);
|
|
@@ -14,9 +17,9 @@ export const Float8Type = {
|
|
|
14
17
|
return typeof v === 'number';
|
|
15
18
|
},
|
|
16
19
|
};
|
|
17
|
-
|
|
18
|
-
...Float8Type,
|
|
20
|
+
exports.ArrayFloat8Type = {
|
|
21
|
+
...exports.Float8Type,
|
|
19
22
|
name: '_float8',
|
|
20
|
-
oid: DataTypeOIDs._float8,
|
|
21
|
-
elementsOID: DataTypeOIDs.float8,
|
|
23
|
+
oid: constants_js_1.DataTypeOIDs._float8,
|
|
24
|
+
elementsOID: constants_js_1.DataTypeOIDs.float8,
|
|
22
25
|
};
|
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrayInt2Type = exports.Int2Type = void 0;
|
|
4
|
+
const constants_js_1 = require("../constants.js");
|
|
5
|
+
const fast_parseint_js_1 = require("../util/fast-parseint.js");
|
|
6
|
+
exports.Int2Type = {
|
|
4
7
|
name: 'int2',
|
|
5
|
-
oid: DataTypeOIDs.int2,
|
|
8
|
+
oid: constants_js_1.DataTypeOIDs.int2,
|
|
6
9
|
jsType: 'number',
|
|
7
10
|
parseBinary(v) {
|
|
8
11
|
return v.readInt16BE(0);
|
|
9
12
|
},
|
|
10
13
|
encodeBinary(buf, v) {
|
|
11
|
-
buf.writeInt16BE(fastParseInt(v));
|
|
14
|
+
buf.writeInt16BE((0, fast_parseint_js_1.fastParseInt)(v));
|
|
12
15
|
},
|
|
13
|
-
parseText: fastParseInt,
|
|
16
|
+
parseText: fast_parseint_js_1.fastParseInt,
|
|
14
17
|
isType(v) {
|
|
15
18
|
return typeof v === 'number' && Number.isInteger(v) && v >= -32768 && v <= 32767;
|
|
16
19
|
},
|
|
17
20
|
};
|
|
18
|
-
|
|
19
|
-
...Int2Type,
|
|
21
|
+
exports.ArrayInt2Type = {
|
|
22
|
+
...exports.Int2Type,
|
|
20
23
|
name: '_int2',
|
|
21
|
-
oid: DataTypeOIDs._int2,
|
|
22
|
-
elementsOID: DataTypeOIDs.int2,
|
|
24
|
+
oid: constants_js_1.DataTypeOIDs._int2,
|
|
25
|
+
elementsOID: constants_js_1.DataTypeOIDs.int2,
|
|
23
26
|
};
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrayInt2VectorType = exports.Int2VectorType = void 0;
|
|
4
|
+
const constants_js_1 = require("../constants.js");
|
|
5
|
+
const decode_binaryarray_js_1 = require("../util/decode-binaryarray.js");
|
|
6
|
+
const encode_binaryarray_js_1 = require("../util/encode-binaryarray.js");
|
|
7
|
+
const fast_parseint_js_1 = require("../util/fast-parseint.js");
|
|
8
|
+
exports.Int2VectorType = {
|
|
6
9
|
name: 'int2vector',
|
|
7
|
-
oid: DataTypeOIDs.int2vector,
|
|
10
|
+
oid: constants_js_1.DataTypeOIDs.int2vector,
|
|
8
11
|
jsType: 'array',
|
|
9
12
|
parseBinary(v) {
|
|
10
|
-
return decodeBinaryArray(v, b => b.readInt16BE()) || undefined;
|
|
13
|
+
return (0, decode_binaryarray_js_1.decodeBinaryArray)(v, b => b.readInt16BE()) || undefined;
|
|
11
14
|
},
|
|
12
15
|
encodeBinary(buf, v) {
|
|
13
|
-
encodeBinaryArray(buf, v, DataTypeOIDs.int2, {}, (io, x) => {
|
|
16
|
+
(0, encode_binaryarray_js_1.encodeBinaryArray)(buf, v, constants_js_1.DataTypeOIDs.int2, {}, (io, x) => {
|
|
14
17
|
io.writeInt16BE(x);
|
|
15
18
|
});
|
|
16
19
|
},
|
|
@@ -18,7 +21,7 @@ export const Int2VectorType = {
|
|
|
18
21
|
return [v.length];
|
|
19
22
|
},
|
|
20
23
|
parseText(str) {
|
|
21
|
-
return str.split(' ').map(fastParseInt);
|
|
24
|
+
return str.split(' ').map(fast_parseint_js_1.fastParseInt);
|
|
22
25
|
},
|
|
23
26
|
encodeText(v) {
|
|
24
27
|
return v.join(' ');
|
|
@@ -27,9 +30,9 @@ export const Int2VectorType = {
|
|
|
27
30
|
return (Array.isArray(v) && !v.find(x => !(typeof x === 'number' && Number.isInteger(x) && x >= -32768 && x <= 32767)));
|
|
28
31
|
},
|
|
29
32
|
};
|
|
30
|
-
|
|
31
|
-
...Int2VectorType,
|
|
33
|
+
exports.ArrayInt2VectorType = {
|
|
34
|
+
...exports.Int2VectorType,
|
|
32
35
|
name: '_int2vector',
|
|
33
|
-
oid: DataTypeOIDs._int2vector,
|
|
34
|
-
elementsOID: DataTypeOIDs.int2vector,
|
|
36
|
+
oid: constants_js_1.DataTypeOIDs._int2vector,
|
|
37
|
+
elementsOID: constants_js_1.DataTypeOIDs.int2vector,
|
|
35
38
|
};
|
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrayInt4Type = exports.Int4Type = void 0;
|
|
4
|
+
const constants_js_1 = require("../constants.js");
|
|
5
|
+
const fast_parseint_js_1 = require("../util/fast-parseint.js");
|
|
6
|
+
exports.Int4Type = {
|
|
4
7
|
name: 'int4',
|
|
5
|
-
oid: DataTypeOIDs.int4,
|
|
8
|
+
oid: constants_js_1.DataTypeOIDs.int4,
|
|
6
9
|
jsType: 'number',
|
|
7
10
|
parseBinary(v) {
|
|
8
11
|
return v.readInt32BE(0);
|
|
9
12
|
},
|
|
10
13
|
encodeBinary(buf, v) {
|
|
11
|
-
buf.writeInt32BE(fastParseInt(v));
|
|
14
|
+
buf.writeInt32BE((0, fast_parseint_js_1.fastParseInt)(v));
|
|
12
15
|
},
|
|
13
|
-
parseText: fastParseInt,
|
|
16
|
+
parseText: fast_parseint_js_1.fastParseInt,
|
|
14
17
|
isType(v) {
|
|
15
18
|
return typeof v === 'number' && Number.isInteger(v) && v <= Number.MAX_SAFE_INTEGER;
|
|
16
19
|
},
|
|
17
20
|
};
|
|
18
|
-
|
|
19
|
-
...Int4Type,
|
|
21
|
+
exports.ArrayInt4Type = {
|
|
22
|
+
...exports.Int4Type,
|
|
20
23
|
name: '_int4',
|
|
21
|
-
oid: DataTypeOIDs._int4,
|
|
22
|
-
elementsOID: DataTypeOIDs.int4,
|
|
24
|
+
oid: constants_js_1.DataTypeOIDs._int4,
|
|
25
|
+
elementsOID: constants_js_1.DataTypeOIDs.int4,
|
|
23
26
|
};
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrayInt8Type = exports.Int8Type = void 0;
|
|
4
|
+
const constants_js_1 = require("../constants.js");
|
|
5
|
+
const bigint_methods_js_1 = require("../util/bigint-methods.js");
|
|
3
6
|
const maxSafeInteger = BigInt(Number.MAX_SAFE_INTEGER);
|
|
4
|
-
|
|
7
|
+
exports.Int8Type = {
|
|
5
8
|
name: 'int8',
|
|
6
|
-
oid: DataTypeOIDs.int8,
|
|
9
|
+
oid: constants_js_1.DataTypeOIDs.int8,
|
|
7
10
|
jsType: 'BigInt',
|
|
8
11
|
parseBinary(buf) {
|
|
9
|
-
const v = typeof buf.readBigInt64BE === 'function' ? buf.readBigInt64BE(0) : readBigInt64BE(buf);
|
|
12
|
+
const v = typeof buf.readBigInt64BE === 'function' ? buf.readBigInt64BE(0) : (0, bigint_methods_js_1.readBigInt64BE)(buf);
|
|
10
13
|
return v >= -maxSafeInteger && v <= maxSafeInteger ? Number(v) : v;
|
|
11
14
|
},
|
|
12
15
|
encodeBinary(buf, v) {
|
|
@@ -20,9 +23,9 @@ export const Int8Type = {
|
|
|
20
23
|
return typeof v === 'bigint' || (typeof v === 'number' && Number.isInteger(v) && v > Number.MAX_SAFE_INTEGER);
|
|
21
24
|
},
|
|
22
25
|
};
|
|
23
|
-
|
|
24
|
-
...Int8Type,
|
|
26
|
+
exports.ArrayInt8Type = {
|
|
27
|
+
...exports.Int8Type,
|
|
25
28
|
name: '_int8',
|
|
26
|
-
oid: DataTypeOIDs._int8,
|
|
27
|
-
elementsOID: DataTypeOIDs.int8,
|
|
29
|
+
oid: constants_js_1.DataTypeOIDs._int8,
|
|
30
|
+
elementsOID: constants_js_1.DataTypeOIDs.int8,
|
|
28
31
|
};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrayJsonType = exports.JsonType = void 0;
|
|
4
|
+
const constants_js_1 = require("../constants.js");
|
|
5
|
+
exports.JsonType = {
|
|
3
6
|
name: 'json',
|
|
4
|
-
oid: DataTypeOIDs.json,
|
|
7
|
+
oid: constants_js_1.DataTypeOIDs.json,
|
|
5
8
|
jsType: 'string',
|
|
6
9
|
parseBinary(v, options) {
|
|
7
10
|
const content = v.toString('utf8');
|
|
8
|
-
const fetchAsString = options.fetchAsString && options.fetchAsString.includes(DataTypeOIDs.jsonb);
|
|
11
|
+
const fetchAsString = options.fetchAsString && options.fetchAsString.includes(constants_js_1.DataTypeOIDs.jsonb);
|
|
9
12
|
if (fetchAsString)
|
|
10
13
|
return content;
|
|
11
14
|
return content ? JSON.parse(content) : undefined;
|
|
@@ -18,7 +21,7 @@ export const JsonType = {
|
|
|
18
21
|
return '' + v;
|
|
19
22
|
},
|
|
20
23
|
parseText(v, options) {
|
|
21
|
-
const fetchAsString = options.fetchAsString && options.fetchAsString.includes(DataTypeOIDs.jsonb);
|
|
24
|
+
const fetchAsString = options.fetchAsString && options.fetchAsString.includes(constants_js_1.DataTypeOIDs.jsonb);
|
|
22
25
|
if (fetchAsString)
|
|
23
26
|
return v;
|
|
24
27
|
return v ? JSON.parse(v) : null;
|
|
@@ -27,9 +30,9 @@ export const JsonType = {
|
|
|
27
30
|
return v && typeof v === 'object';
|
|
28
31
|
},
|
|
29
32
|
};
|
|
30
|
-
|
|
31
|
-
...JsonType,
|
|
33
|
+
exports.ArrayJsonType = {
|
|
34
|
+
...exports.JsonType,
|
|
32
35
|
name: '_json',
|
|
33
|
-
oid: DataTypeOIDs._json,
|
|
34
|
-
elementsOID: DataTypeOIDs.json,
|
|
36
|
+
oid: constants_js_1.DataTypeOIDs._json,
|
|
37
|
+
elementsOID: constants_js_1.DataTypeOIDs.json,
|
|
35
38
|
};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrayJsonbType = exports.JsonbType = void 0;
|
|
4
|
+
const constants_js_1 = require("../constants.js");
|
|
5
|
+
const buffer_reader_js_1 = require("../protocol/buffer-reader.js");
|
|
6
|
+
exports.JsonbType = {
|
|
4
7
|
name: 'jsonb',
|
|
5
|
-
oid: DataTypeOIDs.jsonb,
|
|
8
|
+
oid: constants_js_1.DataTypeOIDs.jsonb,
|
|
6
9
|
jsType: 'string',
|
|
7
10
|
parseBinary(v, options) {
|
|
8
|
-
const buf = new BufferReader(v);
|
|
11
|
+
const buf = new buffer_reader_js_1.BufferReader(v);
|
|
9
12
|
if (buf.readUInt8() !== 1)
|
|
10
13
|
throw new Error('Unexpected Jsonb version value in header');
|
|
11
|
-
const fetchAsString = options.fetchAsString && options.fetchAsString.includes(DataTypeOIDs.json);
|
|
14
|
+
const fetchAsString = options.fetchAsString && options.fetchAsString.includes(constants_js_1.DataTypeOIDs.json);
|
|
12
15
|
const content = buf.readLString(buf.length - buf.offset);
|
|
13
16
|
if (fetchAsString)
|
|
14
17
|
return content;
|
|
@@ -22,7 +25,7 @@ export const JsonbType = {
|
|
|
22
25
|
return '\x0001' + v;
|
|
23
26
|
},
|
|
24
27
|
parseText(v, options) {
|
|
25
|
-
const fetchAsString = options.fetchAsString && options.fetchAsString.includes(DataTypeOIDs.json);
|
|
28
|
+
const fetchAsString = options.fetchAsString && options.fetchAsString.includes(constants_js_1.DataTypeOIDs.json);
|
|
26
29
|
if (fetchAsString)
|
|
27
30
|
return v;
|
|
28
31
|
return v ? JSON.parse(v) : null;
|
|
@@ -31,9 +34,9 @@ export const JsonbType = {
|
|
|
31
34
|
return v && typeof v === 'object';
|
|
32
35
|
},
|
|
33
36
|
};
|
|
34
|
-
|
|
35
|
-
...JsonbType,
|
|
37
|
+
exports.ArrayJsonbType = {
|
|
38
|
+
...exports.JsonbType,
|
|
36
39
|
name: '_jsonb',
|
|
37
|
-
oid: DataTypeOIDs._jsonb,
|
|
38
|
-
elementsOID: DataTypeOIDs.jsonb,
|
|
40
|
+
oid: constants_js_1.DataTypeOIDs._jsonb,
|
|
41
|
+
elementsOID: constants_js_1.DataTypeOIDs.jsonb,
|
|
39
42
|
};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrayLsegType = exports.LsegType = void 0;
|
|
4
|
+
const constants_js_1 = require("../constants.js");
|
|
2
5
|
const LSEG_PATTERN1 = /^\[ *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *]$/;
|
|
3
6
|
const LSEG_PATTERN2 = /^\( *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *\)$/;
|
|
4
7
|
const LSEG_PATTERN3 = /^\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\)$/;
|
|
5
8
|
const LSEG_PATTERN4 = /^(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *, *(-?\d+\.?\d*)$/;
|
|
6
|
-
|
|
9
|
+
exports.LsegType = {
|
|
7
10
|
name: 'lseg',
|
|
8
|
-
oid: DataTypeOIDs.lseg,
|
|
11
|
+
oid: constants_js_1.DataTypeOIDs.lseg,
|
|
9
12
|
jsType: 'object',
|
|
10
13
|
parseBinary(v) {
|
|
11
14
|
return {
|
|
@@ -41,9 +44,9 @@ export const LsegType = {
|
|
|
41
44
|
typeof v.y2 === 'number');
|
|
42
45
|
},
|
|
43
46
|
};
|
|
44
|
-
|
|
45
|
-
...LsegType,
|
|
47
|
+
exports.ArrayLsegType = {
|
|
48
|
+
...exports.LsegType,
|
|
46
49
|
name: '_lseg',
|
|
47
|
-
oid: DataTypeOIDs._lseg,
|
|
48
|
-
elementsOID: DataTypeOIDs.lseg,
|
|
50
|
+
oid: constants_js_1.DataTypeOIDs._lseg,
|
|
51
|
+
elementsOID: constants_js_1.DataTypeOIDs.lseg,
|
|
49
52
|
};
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrayNumericType = exports.NumericType = void 0;
|
|
4
|
+
exports.numberBytesToString = numberBytesToString;
|
|
5
|
+
const constants_js_1 = require("../constants.js");
|
|
2
6
|
const NUMERIC_NEG = 0x4000;
|
|
3
7
|
const NUMERIC_NAN = 0xc000;
|
|
4
8
|
const DEC_DIGITS = 4;
|
|
5
9
|
const ROUND_POWERS = [0, 1000, 100, 10];
|
|
6
|
-
|
|
10
|
+
exports.NumericType = {
|
|
7
11
|
name: 'numeric',
|
|
8
|
-
oid: DataTypeOIDs.numeric,
|
|
12
|
+
oid: constants_js_1.DataTypeOIDs.numeric,
|
|
9
13
|
jsType: 'number',
|
|
10
14
|
parseBinary(v) {
|
|
11
15
|
const len = v.readInt16BE();
|
|
@@ -30,11 +34,11 @@ export const NumericType = {
|
|
|
30
34
|
return typeof v === 'number';
|
|
31
35
|
},
|
|
32
36
|
};
|
|
33
|
-
|
|
34
|
-
...NumericType,
|
|
37
|
+
exports.ArrayNumericType = {
|
|
38
|
+
...exports.NumericType,
|
|
35
39
|
name: '_numeric',
|
|
36
|
-
oid: DataTypeOIDs._numeric,
|
|
37
|
-
elementsOID: DataTypeOIDs.numeric,
|
|
40
|
+
oid: constants_js_1.DataTypeOIDs._numeric,
|
|
41
|
+
elementsOID: constants_js_1.DataTypeOIDs.numeric,
|
|
38
42
|
};
|
|
39
43
|
/* https://github.com/pgjdbc/pgjdbc/blob/3eca3a76aa4a04cb28cb960ed674cb67db30b5e3/pgjdbc/src/main/java/org/postgresql/util/ByteConverter.java */
|
|
40
44
|
/**
|
|
@@ -45,7 +49,7 @@ export const ArrayNumericType = {
|
|
|
45
49
|
* @param sign the sign of the number
|
|
46
50
|
* @return String the number as String
|
|
47
51
|
*/
|
|
48
|
-
|
|
52
|
+
function numberBytesToString(digits, scale, weight, sign) {
|
|
49
53
|
let i;
|
|
50
54
|
let d;
|
|
51
55
|
/*
|
|
@@ -1,29 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VectorOidType = exports.ArrayOidType = exports.OidType = void 0;
|
|
4
|
+
const constants_js_1 = require("../constants.js");
|
|
5
|
+
const fast_parseint_js_1 = require("../util/fast-parseint.js");
|
|
6
|
+
exports.OidType = {
|
|
4
7
|
name: 'oid',
|
|
5
|
-
oid: DataTypeOIDs.oid,
|
|
8
|
+
oid: constants_js_1.DataTypeOIDs.oid,
|
|
6
9
|
jsType: 'number',
|
|
7
10
|
parseBinary(v) {
|
|
8
11
|
return v.readUInt32BE(0);
|
|
9
12
|
},
|
|
10
13
|
encodeBinary(buf, v) {
|
|
11
|
-
buf.writeUInt32BE(fastParseInt(v));
|
|
14
|
+
buf.writeUInt32BE((0, fast_parseint_js_1.fastParseInt)(v));
|
|
12
15
|
},
|
|
13
|
-
parseText: fastParseInt,
|
|
16
|
+
parseText: fast_parseint_js_1.fastParseInt,
|
|
14
17
|
isType(v) {
|
|
15
|
-
return typeof v === 'number' && Number.isInteger(v) && !!DataTypeNames[v];
|
|
18
|
+
return typeof v === 'number' && Number.isInteger(v) && !!constants_js_1.DataTypeNames[v];
|
|
16
19
|
},
|
|
17
20
|
};
|
|
18
|
-
|
|
19
|
-
...OidType,
|
|
21
|
+
exports.ArrayOidType = {
|
|
22
|
+
...exports.OidType,
|
|
20
23
|
name: '_oid',
|
|
21
|
-
oid: DataTypeOIDs._oid,
|
|
22
|
-
elementsOID: DataTypeOIDs.oid,
|
|
24
|
+
oid: constants_js_1.DataTypeOIDs._oid,
|
|
25
|
+
elementsOID: constants_js_1.DataTypeOIDs.oid,
|
|
23
26
|
};
|
|
24
|
-
|
|
25
|
-
...OidType,
|
|
27
|
+
exports.VectorOidType = {
|
|
28
|
+
...exports.OidType,
|
|
26
29
|
name: '_oidvector',
|
|
27
|
-
oid: DataTypeOIDs.oidvector,
|
|
28
|
-
elementsOID: DataTypeOIDs.oid,
|
|
30
|
+
oid: constants_js_1.DataTypeOIDs.oidvector,
|
|
31
|
+
elementsOID: constants_js_1.DataTypeOIDs.oid,
|
|
29
32
|
};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrayPointType = exports.PointType = void 0;
|
|
4
|
+
const constants_js_1 = require("../constants.js");
|
|
2
5
|
const POINT_PATTERN1 = /^\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\)$/;
|
|
3
6
|
const POINT_PATTERN2 = /^(-?\d+\.?\d*) *, *(-?\d+\.?\d*)$/;
|
|
4
|
-
|
|
7
|
+
exports.PointType = {
|
|
5
8
|
name: 'point',
|
|
6
|
-
oid: DataTypeOIDs.point,
|
|
9
|
+
oid: constants_js_1.DataTypeOIDs.point,
|
|
7
10
|
jsType: 'object',
|
|
8
11
|
parseBinary(v) {
|
|
9
12
|
return {
|
|
@@ -28,9 +31,9 @@ export const PointType = {
|
|
|
28
31
|
return typeof v === 'object' && Object.keys(v).length === 2 && typeof v.x === 'number' && typeof v.y === 'number';
|
|
29
32
|
},
|
|
30
33
|
};
|
|
31
|
-
|
|
32
|
-
...PointType,
|
|
34
|
+
exports.ArrayPointType = {
|
|
35
|
+
...exports.PointType,
|
|
33
36
|
name: '_point',
|
|
34
|
-
oid: DataTypeOIDs._point,
|
|
35
|
-
elementsOID: DataTypeOIDs.point,
|
|
37
|
+
oid: constants_js_1.DataTypeOIDs._point,
|
|
38
|
+
elementsOID: constants_js_1.DataTypeOIDs.point,
|
|
36
39
|
};
|