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