postgrejs 2.22.9 → 2.23.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 +8 -1
- package/{esm/connection → connection}/bind-param.js +2 -0
- package/{esm/connection → connection}/connection.js +4 -2
- package/{esm/connection → connection}/cursor.js +8 -3
- package/{esm/connection → connection}/intl-connection.js +6 -3
- package/{esm/connection → connection}/pool.js +4 -1
- package/{esm/connection → connection}/portal.js +3 -1
- package/{esm/connection → connection}/prepared-statement.js +6 -3
- package/{esm/constants.js → constants.js} +1 -1
- package/{esm/data-type-map.js → data-type-map.js} +2 -2
- package/package.json +12 -31
- package/{esm/protocol → protocol}/backend.js +1 -0
- package/{esm/protocol → protocol}/buffer-reader.js +2 -1
- package/{esm/protocol → protocol}/database-error.js +16 -0
- package/{esm/protocol → protocol}/frontend.js +1 -0
- package/{esm/protocol → protocol}/pg-socket.js +9 -3
- package/{esm/protocol → protocol}/smart-buffer.js +9 -5
- package/{esm/util → util}/bigint-methods.js +1 -0
- package/cjs/connection/bind-param.js +0 -10
- package/cjs/connection/connection.js +0 -295
- package/cjs/connection/cursor.js +0 -91
- package/cjs/connection/intl-connection.js +0 -258
- package/cjs/connection/pool.js +0 -236
- package/cjs/connection/portal.js +0 -157
- package/cjs/connection/prepared-statement.js +0 -226
- package/cjs/constants.js +0 -249
- package/cjs/data-type-map.js +0 -131
- package/cjs/data-types/bool-type.js +0 -33
- package/cjs/data-types/box-type.js +0 -52
- package/cjs/data-types/bytea-type.js +0 -28
- package/cjs/data-types/char-type.js +0 -27
- package/cjs/data-types/circle-type.js +0 -51
- package/cjs/data-types/date-type.js +0 -75
- package/cjs/data-types/float4-type.js +0 -25
- package/cjs/data-types/float8-type.js +0 -25
- package/cjs/data-types/int2-type.js +0 -26
- package/cjs/data-types/int2-vector-type.js +0 -42
- package/cjs/data-types/int4-type.js +0 -28
- package/cjs/data-types/int8-type.js +0 -36
- package/cjs/data-types/json-type.js +0 -40
- package/cjs/data-types/jsonb-type.js +0 -44
- package/cjs/data-types/lseg-type.js +0 -55
- package/cjs/data-types/numeric-type.js +0 -125
- package/cjs/data-types/oid-type.js +0 -32
- package/cjs/data-types/point-type.js +0 -42
- package/cjs/data-types/time-type.js +0 -66
- package/cjs/data-types/timestamp-type.js +0 -89
- package/cjs/data-types/timestamptz-type.js +0 -76
- package/cjs/data-types/uuid-type.js +0 -39
- package/cjs/data-types/varchar-type.js +0 -27
- package/cjs/index.js +0 -28
- package/cjs/interfaces/command-result.js +0 -2
- package/cjs/interfaces/data-mapping-options.js +0 -2
- package/cjs/interfaces/data-type.js +0 -2
- package/cjs/interfaces/database-connection-params.js +0 -2
- package/cjs/interfaces/field-info.js +0 -2
- package/cjs/interfaces/query-options.js +0 -2
- package/cjs/interfaces/query-result.js +0 -2
- package/cjs/interfaces/script-execute-options.js +0 -2
- package/cjs/interfaces/script-result.js +0 -2
- package/cjs/interfaces/statement-prepare-options.js +0 -2
- package/cjs/package.json +0 -3
- package/cjs/protocol/backend.js +0 -262
- package/cjs/protocol/buffer-reader.js +0 -78
- package/cjs/protocol/database-error.js +0 -17
- package/cjs/protocol/frontend.js +0 -255
- package/cjs/protocol/pg-socket.js +0 -367
- package/cjs/protocol/protocol.js +0 -71
- package/cjs/protocol/sasl.js +0 -108
- package/cjs/protocol/smart-buffer.js +0 -178
- package/cjs/safe-event-emitter.js +0 -17
- package/cjs/tsconfig-build-cjs.tsbuildinfo +0 -1
- package/cjs/types.js +0 -2
- package/cjs/util/array-calculatedim.js +0 -18
- package/cjs/util/bigint-methods.js +0 -44
- package/cjs/util/config-from-env.js +0 -29
- package/cjs/util/connection-config.js +0 -61
- package/cjs/util/convert-row-to-object.js +0 -12
- package/cjs/util/decode-binaryarray.js +0 -38
- package/cjs/util/encode-binaryarray.js +0 -44
- package/cjs/util/escape-literal.js +0 -26
- package/cjs/util/fast-parseint.js +0 -31
- package/cjs/util/get-parsers.js +0 -41
- package/cjs/util/parse-array.js +0 -60
- package/cjs/util/parse-datetime.js +0 -37
- package/cjs/util/parse-row.js +0 -11
- package/cjs/util/parse-time.js +0 -30
- package/cjs/util/stringify-arrayliteral.js +0 -37
- package/cjs/util/stringify-for-sql.js +0 -29
- package/cjs/util/wrap-row-description.js +0 -34
- package/esm/package.json +0 -3
- package/types/index.d.cts +0 -25
- /package/{types/connection → connection}/bind-param.d.ts +0 -0
- /package/{types/connection → connection}/connection.d.ts +0 -0
- /package/{types/connection → connection}/cursor.d.ts +0 -0
- /package/{types/connection → connection}/intl-connection.d.ts +0 -0
- /package/{types/connection → connection}/pool.d.ts +0 -0
- /package/{types/connection → connection}/portal.d.ts +0 -0
- /package/{types/connection → connection}/prepared-statement.d.ts +0 -0
- /package/{types/constants.d.ts → constants.d.ts} +0 -0
- /package/{types/data-type-map.d.ts → data-type-map.d.ts} +0 -0
- /package/{types/data-types → data-types}/bool-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/bool-type.js +0 -0
- /package/{types/data-types → data-types}/box-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/box-type.js +0 -0
- /package/{types/data-types → data-types}/bytea-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/bytea-type.js +0 -0
- /package/{types/data-types → data-types}/char-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/char-type.js +0 -0
- /package/{types/data-types → data-types}/circle-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/circle-type.js +0 -0
- /package/{types/data-types → data-types}/date-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/date-type.js +0 -0
- /package/{types/data-types → data-types}/float4-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/float4-type.js +0 -0
- /package/{types/data-types → data-types}/float8-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/float8-type.js +0 -0
- /package/{types/data-types → data-types}/int2-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/int2-type.js +0 -0
- /package/{types/data-types → data-types}/int2-vector-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/int2-vector-type.js +0 -0
- /package/{types/data-types → data-types}/int4-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/int4-type.js +0 -0
- /package/{types/data-types → data-types}/int8-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/int8-type.js +0 -0
- /package/{types/data-types → data-types}/json-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/json-type.js +0 -0
- /package/{types/data-types → data-types}/jsonb-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/jsonb-type.js +0 -0
- /package/{types/data-types → data-types}/lseg-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/lseg-type.js +0 -0
- /package/{types/data-types → data-types}/numeric-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/numeric-type.js +0 -0
- /package/{types/data-types → data-types}/oid-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/oid-type.js +0 -0
- /package/{types/data-types → data-types}/point-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/point-type.js +0 -0
- /package/{types/data-types → data-types}/time-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/time-type.js +0 -0
- /package/{types/data-types → data-types}/timestamp-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/timestamp-type.js +0 -0
- /package/{types/data-types → data-types}/timestamptz-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/timestamptz-type.js +0 -0
- /package/{types/data-types → data-types}/uuid-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/uuid-type.js +0 -0
- /package/{types/data-types → data-types}/varchar-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/varchar-type.js +0 -0
- /package/{types/index.d.ts → index.d.ts} +0 -0
- /package/{esm/index.js → index.js} +0 -0
- /package/{types/interfaces → interfaces}/command-result.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/command-result.js +0 -0
- /package/{types/interfaces → interfaces}/data-mapping-options.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/data-mapping-options.js +0 -0
- /package/{types/interfaces → interfaces}/data-type.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/data-type.js +0 -0
- /package/{types/interfaces → interfaces}/database-connection-params.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/database-connection-params.js +0 -0
- /package/{types/interfaces → interfaces}/field-info.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/field-info.js +0 -0
- /package/{types/interfaces → interfaces}/query-options.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/query-options.js +0 -0
- /package/{types/interfaces → interfaces}/query-result.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/query-result.js +0 -0
- /package/{types/interfaces → interfaces}/script-execute-options.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/script-execute-options.js +0 -0
- /package/{types/interfaces → interfaces}/script-result.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/script-result.js +0 -0
- /package/{types/interfaces → interfaces}/statement-prepare-options.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/statement-prepare-options.js +0 -0
- /package/{types/protocol → protocol}/backend.d.ts +0 -0
- /package/{types/protocol → protocol}/buffer-reader.d.ts +0 -0
- /package/{types/protocol → protocol}/database-error.d.ts +0 -0
- /package/{types/protocol → protocol}/frontend.d.ts +0 -0
- /package/{types/protocol → protocol}/pg-socket.d.ts +0 -0
- /package/{types/protocol → protocol}/protocol.d.ts +0 -0
- /package/{esm/protocol → protocol}/protocol.js +0 -0
- /package/{types/protocol → protocol}/sasl.d.ts +0 -0
- /package/{esm/protocol → protocol}/sasl.js +0 -0
- /package/{types/protocol → protocol}/smart-buffer.d.ts +0 -0
- /package/{types/safe-event-emitter.d.ts → safe-event-emitter.d.ts} +0 -0
- /package/{esm/safe-event-emitter.js → safe-event-emitter.js} +0 -0
- /package/{types/types.d.ts → types.d.ts} +0 -0
- /package/{esm/types.js → types.js} +0 -0
- /package/{types/util → util}/array-calculatedim.d.ts +0 -0
- /package/{esm/util → util}/array-calculatedim.js +0 -0
- /package/{types/util → util}/bigint-methods.d.ts +0 -0
- /package/{types/util → util}/config-from-env.d.ts +0 -0
- /package/{esm/util → util}/config-from-env.js +0 -0
- /package/{types/util → util}/connection-config.d.ts +0 -0
- /package/{esm/util → util}/connection-config.js +0 -0
- /package/{types/util → util}/convert-row-to-object.d.ts +0 -0
- /package/{esm/util → util}/convert-row-to-object.js +0 -0
- /package/{types/util → util}/decode-binaryarray.d.ts +0 -0
- /package/{esm/util → util}/decode-binaryarray.js +0 -0
- /package/{types/util → util}/encode-binaryarray.d.ts +0 -0
- /package/{esm/util → util}/encode-binaryarray.js +0 -0
- /package/{types/util → util}/escape-literal.d.ts +0 -0
- /package/{esm/util → util}/escape-literal.js +0 -0
- /package/{types/util → util}/fast-parseint.d.ts +0 -0
- /package/{esm/util → util}/fast-parseint.js +0 -0
- /package/{types/util → util}/get-parsers.d.ts +0 -0
- /package/{esm/util → util}/get-parsers.js +0 -0
- /package/{types/util → util}/parse-array.d.ts +0 -0
- /package/{esm/util → util}/parse-array.js +0 -0
- /package/{types/util → util}/parse-datetime.d.ts +0 -0
- /package/{esm/util → util}/parse-datetime.js +0 -0
- /package/{types/util → util}/parse-row.d.ts +0 -0
- /package/{esm/util → util}/parse-row.js +0 -0
- /package/{types/util → util}/parse-time.d.ts +0 -0
- /package/{esm/util → util}/parse-time.js +0 -0
- /package/{types/util → util}/stringify-arrayliteral.d.ts +0 -0
- /package/{esm/util → util}/stringify-arrayliteral.js +0 -0
- /package/{types/util → util}/stringify-for-sql.d.ts +0 -0
- /package/{esm/util → util}/stringify-for-sql.js +0 -0
- /package/{types/util → util}/wrap-row-description.d.ts +0 -0
- /package/{esm/util → util}/wrap-row-description.js +0 -0
package/cjs/data-type-map.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GlobalTypeMap = exports.DataTypeMap = void 0;
|
|
4
|
-
const constants_js_1 = require("./constants.js");
|
|
5
|
-
const bool_type_js_1 = require("./data-types/bool-type.js");
|
|
6
|
-
const box_type_js_1 = require("./data-types/box-type.js");
|
|
7
|
-
const bytea_type_js_1 = require("./data-types/bytea-type.js");
|
|
8
|
-
const char_type_js_1 = require("./data-types/char-type.js");
|
|
9
|
-
const circle_type_js_1 = require("./data-types/circle-type.js");
|
|
10
|
-
const date_type_js_1 = require("./data-types/date-type.js");
|
|
11
|
-
const float4_type_js_1 = require("./data-types/float4-type.js");
|
|
12
|
-
const float8_type_js_1 = require("./data-types/float8-type.js");
|
|
13
|
-
const int2_type_js_1 = require("./data-types/int2-type.js");
|
|
14
|
-
const int2_vector_type_js_1 = require("./data-types/int2-vector-type.js");
|
|
15
|
-
const int4_type_js_1 = require("./data-types/int4-type.js");
|
|
16
|
-
const int8_type_js_1 = require("./data-types/int8-type.js");
|
|
17
|
-
const json_type_js_1 = require("./data-types/json-type.js");
|
|
18
|
-
const jsonb_type_js_1 = require("./data-types/jsonb-type.js");
|
|
19
|
-
const lseg_type_js_1 = require("./data-types/lseg-type.js");
|
|
20
|
-
const numeric_type_js_1 = require("./data-types/numeric-type.js");
|
|
21
|
-
const oid_type_js_1 = require("./data-types/oid-type.js");
|
|
22
|
-
const point_type_js_1 = require("./data-types/point-type.js");
|
|
23
|
-
const time_type_js_1 = require("./data-types/time-type.js");
|
|
24
|
-
const timestamp_type_js_1 = require("./data-types/timestamp-type.js");
|
|
25
|
-
const timestamptz_type_js_1 = require("./data-types/timestamptz-type.js");
|
|
26
|
-
const uuid_type_js_1 = require("./data-types/uuid-type.js");
|
|
27
|
-
const varchar_type_js_1 = require("./data-types/varchar-type.js");
|
|
28
|
-
class DataTypeMap {
|
|
29
|
-
constructor(other) {
|
|
30
|
-
this._itemsByOID = {};
|
|
31
|
-
this._items = [];
|
|
32
|
-
if (other instanceof DataTypeMap)
|
|
33
|
-
Object.assign(this._items, other._items);
|
|
34
|
-
}
|
|
35
|
-
get(oid) {
|
|
36
|
-
return this._itemsByOID[oid];
|
|
37
|
-
}
|
|
38
|
-
register(dataTypes) {
|
|
39
|
-
dataTypes = Array.isArray(dataTypes) ? dataTypes : [dataTypes];
|
|
40
|
-
for (const t of dataTypes) {
|
|
41
|
-
this._itemsByOID[t.oid] = t;
|
|
42
|
-
const i = this._items.findIndex(tt => tt.oid === t.oid);
|
|
43
|
-
if (i >= 0)
|
|
44
|
-
this._items[i] = t;
|
|
45
|
-
else
|
|
46
|
-
this._items.push(t);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
determine(value) {
|
|
50
|
-
if (value == null)
|
|
51
|
-
return constants_js_1.DataTypeOIDs.unknown;
|
|
52
|
-
const valueIsArray = Array.isArray(value);
|
|
53
|
-
let i;
|
|
54
|
-
let t;
|
|
55
|
-
for (i = this._items.length - 1; i >= 0; i--) {
|
|
56
|
-
t = this._items[i];
|
|
57
|
-
if (valueIsArray) {
|
|
58
|
-
if (t.elementsOID && t.isType(value[0]))
|
|
59
|
-
return t.oid;
|
|
60
|
-
}
|
|
61
|
-
else if (!t.elementsOID && t.isType(value))
|
|
62
|
-
return t.oid;
|
|
63
|
-
}
|
|
64
|
-
return constants_js_1.DataTypeOIDs.unknown;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
exports.DataTypeMap = DataTypeMap;
|
|
68
|
-
exports.GlobalTypeMap = new DataTypeMap();
|
|
69
|
-
exports.GlobalTypeMap.register([oid_type_js_1.OidType, oid_type_js_1.VectorOidType, oid_type_js_1.ArrayOidType]);
|
|
70
|
-
exports.GlobalTypeMap.register([jsonb_type_js_1.JsonbType, jsonb_type_js_1.ArrayJsonbType]);
|
|
71
|
-
exports.GlobalTypeMap.register([json_type_js_1.JsonType, json_type_js_1.ArrayJsonType]);
|
|
72
|
-
exports.GlobalTypeMap.register([bool_type_js_1.BoolType, bool_type_js_1.ArrayBoolType]);
|
|
73
|
-
exports.GlobalTypeMap.register([numeric_type_js_1.NumericType, numeric_type_js_1.ArrayNumericType]);
|
|
74
|
-
exports.GlobalTypeMap.register([float4_type_js_1.Float4Type, float4_type_js_1.ArrayFloat4Type]);
|
|
75
|
-
exports.GlobalTypeMap.register([float8_type_js_1.Float8Type, float8_type_js_1.ArrayFloat8Type]);
|
|
76
|
-
exports.GlobalTypeMap.register([int2_type_js_1.Int2Type, int2_type_js_1.ArrayInt2Type]);
|
|
77
|
-
exports.GlobalTypeMap.register([int4_type_js_1.Int4Type, int4_type_js_1.ArrayInt4Type]);
|
|
78
|
-
exports.GlobalTypeMap.register([int8_type_js_1.Int8Type, int8_type_js_1.ArrayInt8Type]);
|
|
79
|
-
exports.GlobalTypeMap.register([bytea_type_js_1.ByteaType, bytea_type_js_1.ArrayByteaType]);
|
|
80
|
-
exports.GlobalTypeMap.register([circle_type_js_1.CircleType, circle_type_js_1.ArrayCircleType]);
|
|
81
|
-
exports.GlobalTypeMap.register([point_type_js_1.PointType, point_type_js_1.ArrayPointType]);
|
|
82
|
-
exports.GlobalTypeMap.register([lseg_type_js_1.LsegType, lseg_type_js_1.ArrayLsegType]);
|
|
83
|
-
exports.GlobalTypeMap.register([box_type_js_1.BoxType, box_type_js_1.ArrayBoxType]);
|
|
84
|
-
exports.GlobalTypeMap.register([int2_vector_type_js_1.Int2VectorType, int2_vector_type_js_1.ArrayInt2VectorType]);
|
|
85
|
-
exports.GlobalTypeMap.register({
|
|
86
|
-
...varchar_type_js_1.VarcharType,
|
|
87
|
-
name: 'bpchar',
|
|
88
|
-
oid: constants_js_1.DataTypeOIDs.bpchar,
|
|
89
|
-
});
|
|
90
|
-
exports.GlobalTypeMap.register({
|
|
91
|
-
...varchar_type_js_1.ArrayVarcharType,
|
|
92
|
-
name: '_bpchar',
|
|
93
|
-
oid: constants_js_1.DataTypeOIDs._bpchar,
|
|
94
|
-
elementsOID: constants_js_1.DataTypeOIDs.bpchar,
|
|
95
|
-
});
|
|
96
|
-
exports.GlobalTypeMap.register({
|
|
97
|
-
...varchar_type_js_1.VarcharType,
|
|
98
|
-
name: 'name',
|
|
99
|
-
oid: constants_js_1.DataTypeOIDs.name,
|
|
100
|
-
});
|
|
101
|
-
exports.GlobalTypeMap.register({
|
|
102
|
-
...varchar_type_js_1.ArrayVarcharType,
|
|
103
|
-
name: '_name',
|
|
104
|
-
oid: constants_js_1.DataTypeOIDs._name,
|
|
105
|
-
elementsOID: constants_js_1.DataTypeOIDs.name,
|
|
106
|
-
});
|
|
107
|
-
exports.GlobalTypeMap.register({
|
|
108
|
-
...varchar_type_js_1.VarcharType,
|
|
109
|
-
name: 'text',
|
|
110
|
-
oid: constants_js_1.DataTypeOIDs.text,
|
|
111
|
-
});
|
|
112
|
-
exports.GlobalTypeMap.register({
|
|
113
|
-
...varchar_type_js_1.ArrayVarcharType,
|
|
114
|
-
name: '_text',
|
|
115
|
-
oid: constants_js_1.DataTypeOIDs._text,
|
|
116
|
-
elementsOID: constants_js_1.DataTypeOIDs.text,
|
|
117
|
-
});
|
|
118
|
-
exports.GlobalTypeMap.register({ ...varchar_type_js_1.VarcharType, name: 'xml', oid: constants_js_1.DataTypeOIDs.xml });
|
|
119
|
-
exports.GlobalTypeMap.register({
|
|
120
|
-
...varchar_type_js_1.ArrayVarcharType,
|
|
121
|
-
name: '_xml',
|
|
122
|
-
oid: constants_js_1.DataTypeOIDs._xml,
|
|
123
|
-
elementsOID: constants_js_1.DataTypeOIDs.xml,
|
|
124
|
-
});
|
|
125
|
-
exports.GlobalTypeMap.register([varchar_type_js_1.VarcharType, varchar_type_js_1.ArrayVarcharType]);
|
|
126
|
-
exports.GlobalTypeMap.register([uuid_type_js_1.UuidType, uuid_type_js_1.ArrayUuidType]);
|
|
127
|
-
exports.GlobalTypeMap.register([char_type_js_1.CharType, char_type_js_1.ArrayCharType]);
|
|
128
|
-
exports.GlobalTypeMap.register([timestamptz_type_js_1.TimestamptzType, timestamptz_type_js_1.ArrayTimestamptzType]);
|
|
129
|
-
exports.GlobalTypeMap.register([time_type_js_1.TimeType, time_type_js_1.ArrayTimeType]);
|
|
130
|
-
exports.GlobalTypeMap.register([date_type_js_1.DateType, date_type_js_1.ArrayDateType]);
|
|
131
|
-
exports.GlobalTypeMap.register([timestamp_type_js_1.TimestampType, timestamp_type_js_1.ArrayTimestampType]);
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ArrayBoolType = exports.BoolType = void 0;
|
|
4
|
-
const constants_js_1 = require("../constants.js");
|
|
5
|
-
exports.BoolType = {
|
|
6
|
-
name: 'bool',
|
|
7
|
-
oid: constants_js_1.DataTypeOIDs.bool,
|
|
8
|
-
jsType: 'boolean',
|
|
9
|
-
parseBinary(v) {
|
|
10
|
-
return !!v.readUInt8();
|
|
11
|
-
},
|
|
12
|
-
encodeBinary(buf, v) {
|
|
13
|
-
buf.writeInt8(v ? 1 : 0);
|
|
14
|
-
},
|
|
15
|
-
parseText(v) {
|
|
16
|
-
return (v === 'TRUE' ||
|
|
17
|
-
v === 't' ||
|
|
18
|
-
v === 'true' ||
|
|
19
|
-
v === 'y' ||
|
|
20
|
-
v === 'yes' ||
|
|
21
|
-
v === 'on' ||
|
|
22
|
-
v === '1');
|
|
23
|
-
},
|
|
24
|
-
isType(v) {
|
|
25
|
-
return typeof v === 'boolean';
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
exports.ArrayBoolType = {
|
|
29
|
-
...exports.BoolType,
|
|
30
|
-
name: '_bool',
|
|
31
|
-
oid: constants_js_1.DataTypeOIDs._bool,
|
|
32
|
-
elementsOID: constants_js_1.DataTypeOIDs.bool,
|
|
33
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
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");
|
|
5
|
-
const BOX_PATTERN1 = /^\( *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *\)$/;
|
|
6
|
-
const BOX_PATTERN2 = /^\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\)$/;
|
|
7
|
-
const BOX_PATTERN3 = /^(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *, *(-?\d+\.?\d*)$/;
|
|
8
|
-
exports.BoxType = {
|
|
9
|
-
name: 'box',
|
|
10
|
-
oid: constants_js_1.DataTypeOIDs.box,
|
|
11
|
-
jsType: 'object',
|
|
12
|
-
arraySeparator: ';',
|
|
13
|
-
parseBinary(v) {
|
|
14
|
-
return {
|
|
15
|
-
x1: v.readDoubleBE(0),
|
|
16
|
-
y1: v.readDoubleBE(8),
|
|
17
|
-
x2: v.readDoubleBE(16),
|
|
18
|
-
y2: v.readDoubleBE(24),
|
|
19
|
-
};
|
|
20
|
-
},
|
|
21
|
-
encodeBinary(buf, v) {
|
|
22
|
-
buf.writeDoubleBE(v.x1);
|
|
23
|
-
buf.writeDoubleBE(v.y1);
|
|
24
|
-
buf.writeDoubleBE(v.x2);
|
|
25
|
-
buf.writeDoubleBE(v.y2);
|
|
26
|
-
},
|
|
27
|
-
parseText(v) {
|
|
28
|
-
const m = v.match(BOX_PATTERN1) || v.match(BOX_PATTERN2) || v.match(BOX_PATTERN3);
|
|
29
|
-
if (!m)
|
|
30
|
-
return undefined;
|
|
31
|
-
return {
|
|
32
|
-
x1: parseFloat(m[1]),
|
|
33
|
-
y1: parseFloat(m[2]),
|
|
34
|
-
x2: parseFloat(m[3]),
|
|
35
|
-
y2: parseFloat(m[4]),
|
|
36
|
-
};
|
|
37
|
-
},
|
|
38
|
-
isType(v) {
|
|
39
|
-
return (typeof v === 'object' &&
|
|
40
|
-
Object.keys(v).length === 4 &&
|
|
41
|
-
typeof v.x1 === 'number' &&
|
|
42
|
-
typeof v.y1 === 'number' &&
|
|
43
|
-
typeof v.x2 === 'number' &&
|
|
44
|
-
typeof v.y2 === 'number');
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
exports.ArrayBoxType = {
|
|
48
|
-
...exports.BoxType,
|
|
49
|
-
name: '_box',
|
|
50
|
-
oid: constants_js_1.DataTypeOIDs._box,
|
|
51
|
-
elementsOID: constants_js_1.DataTypeOIDs.box,
|
|
52
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ArrayByteaType = exports.ByteaType = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
// @ts-ignore -- no type definitions for decodeBytea
|
|
6
|
-
const postgres_bytea_1 = tslib_1.__importDefault(require("postgres-bytea"));
|
|
7
|
-
const constants_js_1 = require("../constants.js");
|
|
8
|
-
exports.ByteaType = {
|
|
9
|
-
name: 'bytea',
|
|
10
|
-
oid: constants_js_1.DataTypeOIDs.bytea,
|
|
11
|
-
jsType: 'Buffer',
|
|
12
|
-
parseBinary(v) {
|
|
13
|
-
return v;
|
|
14
|
-
},
|
|
15
|
-
encodeBinary(buf, v) {
|
|
16
|
-
buf.writeBuffer(v);
|
|
17
|
-
},
|
|
18
|
-
parseText: postgres_bytea_1.default,
|
|
19
|
-
isType(v) {
|
|
20
|
-
return v instanceof Buffer;
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
exports.ArrayByteaType = {
|
|
24
|
-
...exports.ByteaType,
|
|
25
|
-
name: '_bytea',
|
|
26
|
-
oid: constants_js_1.DataTypeOIDs._bytea,
|
|
27
|
-
elementsOID: constants_js_1.DataTypeOIDs.bytea,
|
|
28
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
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 = {
|
|
6
|
-
name: 'char',
|
|
7
|
-
oid: constants_js_1.DataTypeOIDs.char,
|
|
8
|
-
jsType: 'string',
|
|
9
|
-
parseBinary(v) {
|
|
10
|
-
return v.toString('utf8');
|
|
11
|
-
},
|
|
12
|
-
encodeBinary(buf, v) {
|
|
13
|
-
buf.writeString((v ? '' + v : ' ')[0], 'utf8');
|
|
14
|
-
},
|
|
15
|
-
parseText(v) {
|
|
16
|
-
return '' + v;
|
|
17
|
-
},
|
|
18
|
-
isType(v) {
|
|
19
|
-
return typeof v === 'string' && v.length === 1;
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
exports.ArrayCharType = {
|
|
23
|
-
...exports.CharType,
|
|
24
|
-
name: '_char',
|
|
25
|
-
oid: constants_js_1.DataTypeOIDs._char,
|
|
26
|
-
elementsOID: constants_js_1.DataTypeOIDs.char,
|
|
27
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
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");
|
|
5
|
-
const CIRCLE_PATTERN1 = /^< *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *(-?\d+\.?\d*) *>$/;
|
|
6
|
-
const CIRCLE_PATTERN2 = /^\( *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *(-?\d+\.?\d*) *\)$/;
|
|
7
|
-
const CIRCLE_PATTERN3 = /^\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *(-?\d+\.?\d*)$/;
|
|
8
|
-
const CIRCLE_PATTERN4 = /^(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *, *(-?\d+\.?\d*)$/;
|
|
9
|
-
exports.CircleType = {
|
|
10
|
-
name: 'circle',
|
|
11
|
-
oid: constants_js_1.DataTypeOIDs.circle,
|
|
12
|
-
jsType: 'object',
|
|
13
|
-
parseBinary(v) {
|
|
14
|
-
return {
|
|
15
|
-
x: v.readDoubleBE(0),
|
|
16
|
-
y: v.readDoubleBE(8),
|
|
17
|
-
r: v.readDoubleBE(16),
|
|
18
|
-
};
|
|
19
|
-
},
|
|
20
|
-
encodeBinary(buf, v) {
|
|
21
|
-
buf.writeDoubleBE(v.x);
|
|
22
|
-
buf.writeDoubleBE(v.y);
|
|
23
|
-
buf.writeDoubleBE(v.r);
|
|
24
|
-
},
|
|
25
|
-
parseText(v) {
|
|
26
|
-
const m = v.match(CIRCLE_PATTERN1) ||
|
|
27
|
-
v.match(CIRCLE_PATTERN2) ||
|
|
28
|
-
v.match(CIRCLE_PATTERN3) ||
|
|
29
|
-
v.match(CIRCLE_PATTERN4);
|
|
30
|
-
if (!m)
|
|
31
|
-
return undefined;
|
|
32
|
-
return {
|
|
33
|
-
x: parseFloat(m[1]),
|
|
34
|
-
y: parseFloat(m[2]),
|
|
35
|
-
r: parseFloat(m[3]),
|
|
36
|
-
};
|
|
37
|
-
},
|
|
38
|
-
isType(v) {
|
|
39
|
-
return (typeof v === 'object' &&
|
|
40
|
-
Object.keys(v).length === 3 &&
|
|
41
|
-
typeof v.x === 'number' &&
|
|
42
|
-
typeof v.y === 'number' &&
|
|
43
|
-
typeof v.r === 'number');
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
exports.ArrayCircleType = {
|
|
47
|
-
...exports.CircleType,
|
|
48
|
-
name: '_circle',
|
|
49
|
-
oid: constants_js_1.DataTypeOIDs._circle,
|
|
50
|
-
elementsOID: constants_js_1.DataTypeOIDs.circle,
|
|
51
|
-
};
|
|
@@ -1,75 +0,0 @@
|
|
|
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");
|
|
6
|
-
const timeShift = 946684800000;
|
|
7
|
-
exports.DateType = {
|
|
8
|
-
name: 'date',
|
|
9
|
-
oid: constants_js_1.DataTypeOIDs.date,
|
|
10
|
-
jsType: 'Date',
|
|
11
|
-
parseBinary(v, options) {
|
|
12
|
-
const fetchAsString = options.fetchAsString &&
|
|
13
|
-
options.fetchAsString.includes(constants_js_1.DataTypeOIDs.date);
|
|
14
|
-
const t = v.readInt32BE();
|
|
15
|
-
if (t === 0x7fffffff)
|
|
16
|
-
return fetchAsString ? 'infinity' : Infinity;
|
|
17
|
-
if (t === -0x80000000)
|
|
18
|
-
return fetchAsString ? '-infinity' : -Infinity;
|
|
19
|
-
// Shift from 2000 to 1970
|
|
20
|
-
let d = new Date(t * 1000 * 86400 + timeShift);
|
|
21
|
-
if (fetchAsString || !options.utcDates)
|
|
22
|
-
d = new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate());
|
|
23
|
-
return fetchAsString ? dateToDateString(d) : d;
|
|
24
|
-
},
|
|
25
|
-
encodeBinary(buf, v, options) {
|
|
26
|
-
if (typeof v === 'string')
|
|
27
|
-
v = (0, parse_datetime_js_1.parseDateTime)(v, false, false, options.utcDates);
|
|
28
|
-
if (v === Infinity) {
|
|
29
|
-
buf.writeInt32BE(0x7fffffff);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
if (v === -Infinity) {
|
|
33
|
-
buf.writeInt32BE(-0x80000000);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
if (!(v instanceof Date))
|
|
37
|
-
v = new Date(v);
|
|
38
|
-
let n = options.utcDates
|
|
39
|
-
? v.getTime()
|
|
40
|
-
: v.getTime() - v.getTimezoneOffset() * 60 * 1000;
|
|
41
|
-
n = (n - timeShift) / 1000 / 86400;
|
|
42
|
-
const t = Math.trunc(n + Number.EPSILON);
|
|
43
|
-
buf.writeInt32BE(t);
|
|
44
|
-
},
|
|
45
|
-
parseText(v, options) {
|
|
46
|
-
const fetchAsString = options.fetchAsString &&
|
|
47
|
-
options.fetchAsString.includes(constants_js_1.DataTypeOIDs.date);
|
|
48
|
-
if (fetchAsString)
|
|
49
|
-
return v;
|
|
50
|
-
return (0, parse_datetime_js_1.parseDateTime)(v, false, false, options.utcDates);
|
|
51
|
-
},
|
|
52
|
-
isType(v) {
|
|
53
|
-
return (v instanceof Date &&
|
|
54
|
-
v.getHours() === 0 &&
|
|
55
|
-
v.getMinutes() === 0 &&
|
|
56
|
-
v.getSeconds() === 0 &&
|
|
57
|
-
v.getMilliseconds() === 0);
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
function padZero(v) {
|
|
61
|
-
return v < 9 ? '0' + v : '' + v;
|
|
62
|
-
}
|
|
63
|
-
function dateToDateString(d) {
|
|
64
|
-
return (d.getFullYear() +
|
|
65
|
-
'-' +
|
|
66
|
-
padZero(d.getMonth() + 1) +
|
|
67
|
-
'-' +
|
|
68
|
-
padZero(d.getDate()));
|
|
69
|
-
}
|
|
70
|
-
exports.ArrayDateType = {
|
|
71
|
-
...exports.DateType,
|
|
72
|
-
name: '_date',
|
|
73
|
-
oid: constants_js_1.DataTypeOIDs._date,
|
|
74
|
-
elementsOID: constants_js_1.DataTypeOIDs.date,
|
|
75
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
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 = {
|
|
6
|
-
name: 'float4',
|
|
7
|
-
oid: constants_js_1.DataTypeOIDs.float4,
|
|
8
|
-
jsType: 'number',
|
|
9
|
-
parseBinary(v) {
|
|
10
|
-
return Math.round((v.readFloatBE(0) + Number.EPSILON) * 100) / 100;
|
|
11
|
-
},
|
|
12
|
-
encodeBinary(buf, v) {
|
|
13
|
-
buf.writeFloatBE(typeof v === 'number' ? v : parseFloat(v));
|
|
14
|
-
},
|
|
15
|
-
parseText: parseFloat,
|
|
16
|
-
isType(v) {
|
|
17
|
-
return typeof v === 'number';
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
exports.ArrayFloat4Type = {
|
|
21
|
-
...exports.Float4Type,
|
|
22
|
-
name: '_float4',
|
|
23
|
-
oid: constants_js_1.DataTypeOIDs._float4,
|
|
24
|
-
elementsOID: constants_js_1.DataTypeOIDs.float4,
|
|
25
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
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 = {
|
|
6
|
-
name: 'float8',
|
|
7
|
-
oid: constants_js_1.DataTypeOIDs.float8,
|
|
8
|
-
jsType: 'number',
|
|
9
|
-
parseBinary(v) {
|
|
10
|
-
return v.readDoubleBE(0);
|
|
11
|
-
},
|
|
12
|
-
encodeBinary(buf, v) {
|
|
13
|
-
buf.writeDoubleBE(typeof v === 'number' ? v : parseFloat(v));
|
|
14
|
-
},
|
|
15
|
-
parseText: parseFloat,
|
|
16
|
-
isType(v) {
|
|
17
|
-
return typeof v === 'number';
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
exports.ArrayFloat8Type = {
|
|
21
|
-
...exports.Float8Type,
|
|
22
|
-
name: '_float8',
|
|
23
|
-
oid: constants_js_1.DataTypeOIDs._float8,
|
|
24
|
-
elementsOID: constants_js_1.DataTypeOIDs.float8,
|
|
25
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
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 = {
|
|
7
|
-
name: 'int2',
|
|
8
|
-
oid: constants_js_1.DataTypeOIDs.int2,
|
|
9
|
-
jsType: 'number',
|
|
10
|
-
parseBinary(v) {
|
|
11
|
-
return v.readInt16BE(0);
|
|
12
|
-
},
|
|
13
|
-
encodeBinary(buf, v) {
|
|
14
|
-
buf.writeInt16BE((0, fast_parseint_js_1.fastParseInt)(v));
|
|
15
|
-
},
|
|
16
|
-
parseText: fast_parseint_js_1.fastParseInt,
|
|
17
|
-
isType(v) {
|
|
18
|
-
return (typeof v === 'number' && Number.isInteger(v) && v >= -32768 && v <= 32767);
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
exports.ArrayInt2Type = {
|
|
22
|
-
...exports.Int2Type,
|
|
23
|
-
name: '_int2',
|
|
24
|
-
oid: constants_js_1.DataTypeOIDs._int2,
|
|
25
|
-
elementsOID: constants_js_1.DataTypeOIDs.int2,
|
|
26
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
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 = {
|
|
9
|
-
name: 'int2vector',
|
|
10
|
-
oid: constants_js_1.DataTypeOIDs.int2vector,
|
|
11
|
-
jsType: 'array',
|
|
12
|
-
parseBinary(v) {
|
|
13
|
-
return (0, decode_binaryarray_js_1.decodeBinaryArray)(v, b => b.readInt16BE()) || undefined;
|
|
14
|
-
},
|
|
15
|
-
encodeBinary(buf, v) {
|
|
16
|
-
(0, encode_binaryarray_js_1.encodeBinaryArray)(buf, v, constants_js_1.DataTypeOIDs.int2, {}, (io, x) => {
|
|
17
|
-
io.writeInt16BE(x);
|
|
18
|
-
});
|
|
19
|
-
},
|
|
20
|
-
encodeCalculateDim(v) {
|
|
21
|
-
return [v.length];
|
|
22
|
-
},
|
|
23
|
-
parseText(str) {
|
|
24
|
-
return str.split(' ').map(fast_parseint_js_1.fastParseInt);
|
|
25
|
-
},
|
|
26
|
-
encodeText(v) {
|
|
27
|
-
return v.join(' ');
|
|
28
|
-
},
|
|
29
|
-
isType(v) {
|
|
30
|
-
return (Array.isArray(v) &&
|
|
31
|
-
!v.find(x => !(typeof x === 'number' &&
|
|
32
|
-
Number.isInteger(x) &&
|
|
33
|
-
x >= -32768 &&
|
|
34
|
-
x <= 32767)));
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
exports.ArrayInt2VectorType = {
|
|
38
|
-
...exports.Int2VectorType,
|
|
39
|
-
name: '_int2vector',
|
|
40
|
-
oid: constants_js_1.DataTypeOIDs._int2vector,
|
|
41
|
-
elementsOID: constants_js_1.DataTypeOIDs.int2vector,
|
|
42
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
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 = {
|
|
7
|
-
name: 'int4',
|
|
8
|
-
oid: constants_js_1.DataTypeOIDs.int4,
|
|
9
|
-
jsType: 'number',
|
|
10
|
-
parseBinary(v) {
|
|
11
|
-
return v.readInt32BE(0);
|
|
12
|
-
},
|
|
13
|
-
encodeBinary(buf, v) {
|
|
14
|
-
buf.writeInt32BE((0, fast_parseint_js_1.fastParseInt)(v));
|
|
15
|
-
},
|
|
16
|
-
parseText: fast_parseint_js_1.fastParseInt,
|
|
17
|
-
isType(v) {
|
|
18
|
-
return (typeof v === 'number' &&
|
|
19
|
-
Number.isInteger(v) &&
|
|
20
|
-
v <= Number.MAX_SAFE_INTEGER);
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
exports.ArrayInt4Type = {
|
|
24
|
-
...exports.Int4Type,
|
|
25
|
-
name: '_int4',
|
|
26
|
-
oid: constants_js_1.DataTypeOIDs._int4,
|
|
27
|
-
elementsOID: constants_js_1.DataTypeOIDs.int4,
|
|
28
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
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");
|
|
6
|
-
const maxSafeInteger = BigInt(Number.MAX_SAFE_INTEGER);
|
|
7
|
-
exports.Int8Type = {
|
|
8
|
-
name: 'int8',
|
|
9
|
-
oid: constants_js_1.DataTypeOIDs.int8,
|
|
10
|
-
jsType: 'BigInt',
|
|
11
|
-
parseBinary(buf) {
|
|
12
|
-
const v = typeof buf.readBigInt64BE === 'function'
|
|
13
|
-
? buf.readBigInt64BE(0)
|
|
14
|
-
: (0, bigint_methods_js_1.readBigInt64BE)(buf);
|
|
15
|
-
return v >= -maxSafeInteger && v <= maxSafeInteger ? Number(v) : v;
|
|
16
|
-
},
|
|
17
|
-
encodeBinary(buf, v) {
|
|
18
|
-
buf.writeBigInt64BE(v);
|
|
19
|
-
},
|
|
20
|
-
parseText(s) {
|
|
21
|
-
const v = BigInt(s);
|
|
22
|
-
return v >= -maxSafeInteger && v <= maxSafeInteger ? Number(v) : v;
|
|
23
|
-
},
|
|
24
|
-
isType(v) {
|
|
25
|
-
return (typeof v === 'bigint' ||
|
|
26
|
-
(typeof v === 'number' &&
|
|
27
|
-
Number.isInteger(v) &&
|
|
28
|
-
v > Number.MAX_SAFE_INTEGER));
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
exports.ArrayInt8Type = {
|
|
32
|
-
...exports.Int8Type,
|
|
33
|
-
name: '_int8',
|
|
34
|
-
oid: constants_js_1.DataTypeOIDs._int8,
|
|
35
|
-
elementsOID: constants_js_1.DataTypeOIDs.int8,
|
|
36
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
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 = {
|
|
6
|
-
name: 'json',
|
|
7
|
-
oid: constants_js_1.DataTypeOIDs.json,
|
|
8
|
-
jsType: 'string',
|
|
9
|
-
parseBinary(v, options) {
|
|
10
|
-
const content = v.toString('utf8');
|
|
11
|
-
const fetchAsString = options.fetchAsString &&
|
|
12
|
-
options.fetchAsString.includes(constants_js_1.DataTypeOIDs.jsonb);
|
|
13
|
-
if (fetchAsString)
|
|
14
|
-
return content;
|
|
15
|
-
return content ? JSON.parse(content) : undefined;
|
|
16
|
-
},
|
|
17
|
-
encodeText(v) {
|
|
18
|
-
if (typeof v === 'object' || typeof v === 'bigint')
|
|
19
|
-
return JSON.stringify(v);
|
|
20
|
-
if (typeof v === 'boolean')
|
|
21
|
-
return v ? 'true' : 'false';
|
|
22
|
-
return '' + v;
|
|
23
|
-
},
|
|
24
|
-
parseText(v, options) {
|
|
25
|
-
const fetchAsString = options.fetchAsString &&
|
|
26
|
-
options.fetchAsString.includes(constants_js_1.DataTypeOIDs.jsonb);
|
|
27
|
-
if (fetchAsString)
|
|
28
|
-
return v;
|
|
29
|
-
return v ? JSON.parse(v) : null;
|
|
30
|
-
},
|
|
31
|
-
isType(v) {
|
|
32
|
-
return v && typeof v === 'object';
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
exports.ArrayJsonType = {
|
|
36
|
-
...exports.JsonType,
|
|
37
|
-
name: '_json',
|
|
38
|
-
oid: constants_js_1.DataTypeOIDs._json,
|
|
39
|
-
elementsOID: constants_js_1.DataTypeOIDs.json,
|
|
40
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
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 = {
|
|
7
|
-
name: 'jsonb',
|
|
8
|
-
oid: constants_js_1.DataTypeOIDs.jsonb,
|
|
9
|
-
jsType: 'string',
|
|
10
|
-
parseBinary(v, options) {
|
|
11
|
-
const buf = new buffer_reader_js_1.BufferReader(v);
|
|
12
|
-
if (buf.readUInt8() !== 1)
|
|
13
|
-
throw new Error('Unexpected Jsonb version value in header');
|
|
14
|
-
const fetchAsString = options.fetchAsString &&
|
|
15
|
-
options.fetchAsString.includes(constants_js_1.DataTypeOIDs.json);
|
|
16
|
-
const content = buf.readLString(buf.length - buf.offset);
|
|
17
|
-
if (fetchAsString)
|
|
18
|
-
return content;
|
|
19
|
-
return content ? JSON.parse(content) : undefined;
|
|
20
|
-
},
|
|
21
|
-
encodeText(v) {
|
|
22
|
-
if (typeof v === 'object' || typeof v === 'bigint')
|
|
23
|
-
return JSON.stringify(v);
|
|
24
|
-
if (typeof v === 'boolean')
|
|
25
|
-
return v ? 'true' : 'false';
|
|
26
|
-
return '\x0001' + v;
|
|
27
|
-
},
|
|
28
|
-
parseText(v, options) {
|
|
29
|
-
const fetchAsString = options.fetchAsString &&
|
|
30
|
-
options.fetchAsString.includes(constants_js_1.DataTypeOIDs.json);
|
|
31
|
-
if (fetchAsString)
|
|
32
|
-
return v;
|
|
33
|
-
return v ? JSON.parse(v) : null;
|
|
34
|
-
},
|
|
35
|
-
isType(v) {
|
|
36
|
-
return v && typeof v === 'object';
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
exports.ArrayJsonbType = {
|
|
40
|
-
...exports.JsonbType,
|
|
41
|
-
name: '_jsonb',
|
|
42
|
-
oid: constants_js_1.DataTypeOIDs._jsonb,
|
|
43
|
-
elementsOID: constants_js_1.DataTypeOIDs.jsonb,
|
|
44
|
-
};
|