postgrejs 2.16.0 → 2.17.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 -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 +2 -2
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const cursor_js_1 = require("./cursor.js");
|
|
14
|
-
const intl_connection_js_1 = require("./intl-connection.js");
|
|
15
|
-
const portal_js_1 = require("./portal.js");
|
|
1
|
+
import { coerceToBoolean } from 'putil-varhelpers';
|
|
2
|
+
import { DEFAULT_COLUMN_FORMAT } from '../constants.js';
|
|
3
|
+
import { GlobalTypeMap } from '../data-type-map.js';
|
|
4
|
+
import { Protocol } from '../protocol/protocol.js';
|
|
5
|
+
import { SafeEventEmitter } from '../safe-event-emitter.js';
|
|
6
|
+
import { convertRowToObject } from '../util/convert-row-to-object.js';
|
|
7
|
+
import { getParsers } from '../util/get-parsers.js';
|
|
8
|
+
import { parseRow } from '../util/parse-row.js';
|
|
9
|
+
import { wrapRowDescription } from '../util/wrap-row-description.js';
|
|
10
|
+
import { Cursor } from './cursor.js';
|
|
11
|
+
import { getIntlConnection } from './intl-connection.js';
|
|
12
|
+
import { Portal } from './portal.js';
|
|
16
13
|
let statementCounter = 0;
|
|
17
14
|
let portalCounter = 0;
|
|
18
|
-
class PreparedStatement extends
|
|
15
|
+
export class PreparedStatement extends SafeEventEmitter {
|
|
19
16
|
constructor(connection, sql, paramTypes) {
|
|
20
17
|
super();
|
|
21
18
|
this._sql = '';
|
|
@@ -28,7 +25,7 @@ class PreparedStatement extends safe_event_emitter_js_1.SafeEventEmitter {
|
|
|
28
25
|
this._onErrorSavePoint = 'SP_' + Math.round(Math.random() * 100000000);
|
|
29
26
|
}
|
|
30
27
|
static async prepare(connection, sql, options) {
|
|
31
|
-
const intoCon =
|
|
28
|
+
const intoCon = getIntlConnection(connection);
|
|
32
29
|
intoCon.assertConnected();
|
|
33
30
|
const socket = intoCon.socket;
|
|
34
31
|
const statement = new PreparedStatement(connection, sql, options?.paramTypes);
|
|
@@ -44,7 +41,7 @@ class PreparedStatement extends safe_event_emitter_js_1.SafeEventEmitter {
|
|
|
44
41
|
socket.sendFlushMessage();
|
|
45
42
|
try {
|
|
46
43
|
await socket.capture(async (code, msg, done) => {
|
|
47
|
-
if (code ===
|
|
44
|
+
if (code === Protocol.BackendMessageCode.ParseComplete)
|
|
48
45
|
done();
|
|
49
46
|
// May be Protocol.BackendMessageCode.NoticeResponse
|
|
50
47
|
});
|
|
@@ -52,7 +49,7 @@ class PreparedStatement extends safe_event_emitter_js_1.SafeEventEmitter {
|
|
|
52
49
|
finally {
|
|
53
50
|
socket.sendSyncMessage();
|
|
54
51
|
await socket.capture(async (code, msg, done) => {
|
|
55
|
-
if (code ===
|
|
52
|
+
if (code === Protocol.BackendMessageCode.ReadyForQuery)
|
|
56
53
|
done();
|
|
57
54
|
// May be Protocol.BackendMessageCode.NoticeResponse
|
|
58
55
|
});
|
|
@@ -79,7 +76,7 @@ class PreparedStatement extends safe_event_emitter_js_1.SafeEventEmitter {
|
|
|
79
76
|
return this._paramTypes;
|
|
80
77
|
}
|
|
81
78
|
async execute(options = {}) {
|
|
82
|
-
const intlCon =
|
|
79
|
+
const intlCon = getIntlConnection(this.connection);
|
|
83
80
|
const transactionCommand = this.sql.match(/^(\bBEGIN\b|\bCOMMIT\b|\bSTART\b|\bROLLBACK|SAVEPOINT|RELEASE\b)/i);
|
|
84
81
|
let beginFirst = false;
|
|
85
82
|
let commitLast = false;
|
|
@@ -96,7 +93,7 @@ class PreparedStatement extends safe_event_emitter_js_1.SafeEventEmitter {
|
|
|
96
93
|
const rollbackOnError = !transactionCommand &&
|
|
97
94
|
(options?.rollbackOnError != null
|
|
98
95
|
? options.rollbackOnError
|
|
99
|
-
:
|
|
96
|
+
: coerceToBoolean(intlCon.config.rollbackOnError, true));
|
|
100
97
|
if (intlCon.inTransaction && rollbackOnError)
|
|
101
98
|
await intlCon.execute('SAVEPOINT ' + this._onErrorSavePoint);
|
|
102
99
|
try {
|
|
@@ -119,7 +116,7 @@ class PreparedStatement extends safe_event_emitter_js_1.SafeEventEmitter {
|
|
|
119
116
|
--this._refCount;
|
|
120
117
|
if (this._refCount > 0)
|
|
121
118
|
return;
|
|
122
|
-
const intoCon =
|
|
119
|
+
const intoCon = getIntlConnection(this.connection);
|
|
123
120
|
await intoCon.statementQueue.enqueue(() => this._close()).toPromise();
|
|
124
121
|
}
|
|
125
122
|
async cancel() {
|
|
@@ -127,7 +124,7 @@ class PreparedStatement extends safe_event_emitter_js_1.SafeEventEmitter {
|
|
|
127
124
|
}
|
|
128
125
|
async _execute(options = {}) {
|
|
129
126
|
let portal;
|
|
130
|
-
const intlCon =
|
|
127
|
+
const intlCon = getIntlConnection(this.connection);
|
|
131
128
|
intlCon.ref();
|
|
132
129
|
try {
|
|
133
130
|
const result = { command: undefined };
|
|
@@ -135,19 +132,19 @@ class PreparedStatement extends safe_event_emitter_js_1.SafeEventEmitter {
|
|
|
135
132
|
const t = Date.now();
|
|
136
133
|
// Create portal
|
|
137
134
|
const portalName = 'P_' + ++portalCounter;
|
|
138
|
-
portal = new
|
|
135
|
+
portal = new Portal(this, portalName);
|
|
139
136
|
await portal.bind(options.params, options);
|
|
140
137
|
const fields = await portal.retrieveFields();
|
|
141
|
-
const typeMap = options.typeMap ||
|
|
138
|
+
const typeMap = options.typeMap || GlobalTypeMap;
|
|
142
139
|
let parsers;
|
|
143
140
|
let resultFields;
|
|
144
141
|
if (fields) {
|
|
145
|
-
parsers =
|
|
146
|
-
resultFields =
|
|
142
|
+
parsers = getParsers(typeMap, fields);
|
|
143
|
+
resultFields = wrapRowDescription(typeMap, fields, options.columnFormat || DEFAULT_COLUMN_FORMAT);
|
|
147
144
|
result.fields = resultFields;
|
|
148
145
|
result.rowType = options.objectRows ? 'object' : 'array';
|
|
149
146
|
if (options.cursor) {
|
|
150
|
-
result.cursor = new
|
|
147
|
+
result.cursor = new Cursor(this, portal, resultFields, parsers, options);
|
|
151
148
|
this._refCount++;
|
|
152
149
|
portal = undefined;
|
|
153
150
|
return result;
|
|
@@ -165,9 +162,9 @@ class PreparedStatement extends safe_event_emitter_js_1.SafeEventEmitter {
|
|
|
165
162
|
let row;
|
|
166
163
|
for (let i = 0; i < l; i++) {
|
|
167
164
|
row = rows[i];
|
|
168
|
-
|
|
165
|
+
parseRow(parsers, row, options);
|
|
169
166
|
if (options.objectRows) {
|
|
170
|
-
rows[i] =
|
|
167
|
+
rows[i] = convertRowToObject(resultFields, row);
|
|
171
168
|
}
|
|
172
169
|
}
|
|
173
170
|
}
|
|
@@ -186,7 +183,7 @@ class PreparedStatement extends safe_event_emitter_js_1.SafeEventEmitter {
|
|
|
186
183
|
async _close() {
|
|
187
184
|
if (--this._refCount > 0)
|
|
188
185
|
return;
|
|
189
|
-
const intoCon =
|
|
186
|
+
const intoCon = getIntlConnection(this.connection);
|
|
190
187
|
intoCon.ref();
|
|
191
188
|
try {
|
|
192
189
|
const socket = intoCon.socket;
|
|
@@ -194,12 +191,12 @@ class PreparedStatement extends safe_event_emitter_js_1.SafeEventEmitter {
|
|
|
194
191
|
socket.sendSyncMessage();
|
|
195
192
|
await socket.capture(async (code, msg, done) => {
|
|
196
193
|
switch (code) {
|
|
197
|
-
case
|
|
194
|
+
case Protocol.BackendMessageCode.NoticeResponse:
|
|
198
195
|
this.emit('notice', msg);
|
|
199
196
|
break;
|
|
200
|
-
case
|
|
197
|
+
case Protocol.BackendMessageCode.CloseComplete:
|
|
201
198
|
break;
|
|
202
|
-
case
|
|
199
|
+
case Protocol.BackendMessageCode.ReadyForQuery:
|
|
203
200
|
intoCon.transactionStatus = msg.status;
|
|
204
201
|
done();
|
|
205
202
|
break;
|
|
@@ -217,4 +214,3 @@ class PreparedStatement extends safe_event_emitter_js_1.SafeEventEmitter {
|
|
|
217
214
|
return this.close();
|
|
218
215
|
}
|
|
219
216
|
}
|
|
220
|
-
exports.PreparedStatement = PreparedStatement;
|
package/esm/constants.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.DataTypeNames = exports.DataTypeOIDs = exports.ConnectionState = exports.DEFAULT_COLUMN_FORMAT = exports.DataFormat = void 0;
|
|
4
|
-
const protocol_js_1 = require("./protocol/protocol.js");
|
|
5
|
-
var DataFormat = protocol_js_1.Protocol.DataFormat;
|
|
6
|
-
exports.DataFormat = DataFormat;
|
|
1
|
+
import { Protocol } from './protocol/protocol.js';
|
|
2
|
+
var DataFormat = Protocol.DataFormat;
|
|
7
3
|
// @ts-ignore
|
|
8
4
|
Symbol.asyncDispose ?? (Symbol.asyncDispose = Symbol('Symbol.asyncDispose'));
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
export { DataFormat };
|
|
6
|
+
export const DEFAULT_COLUMN_FORMAT = DataFormat.binary;
|
|
7
|
+
export var ConnectionState;
|
|
11
8
|
(function (ConnectionState) {
|
|
12
9
|
ConnectionState[ConnectionState["CLOSED"] = 0] = "CLOSED";
|
|
13
10
|
ConnectionState[ConnectionState["CONNECTING"] = 1] = "CONNECTING";
|
|
14
11
|
ConnectionState[ConnectionState["AUTHORIZING"] = 3] = "AUTHORIZING";
|
|
15
12
|
ConnectionState[ConnectionState["READY"] = 2] = "READY";
|
|
16
13
|
ConnectionState[ConnectionState["CLOSING"] = 10] = "CLOSING";
|
|
17
|
-
})(ConnectionState || (
|
|
18
|
-
|
|
14
|
+
})(ConnectionState || (ConnectionState = {}));
|
|
15
|
+
export const DataTypeOIDs = {
|
|
19
16
|
bool: 16,
|
|
20
17
|
bytea: 17,
|
|
21
18
|
char: 18,
|
|
@@ -132,119 +129,119 @@ exports.DataTypeOIDs = {
|
|
|
132
129
|
_uuid: 2951,
|
|
133
130
|
_jsonb: 3807,
|
|
134
131
|
};
|
|
135
|
-
|
|
136
|
-
[
|
|
137
|
-
[
|
|
138
|
-
[
|
|
139
|
-
[
|
|
140
|
-
[
|
|
141
|
-
[
|
|
142
|
-
[
|
|
143
|
-
[
|
|
144
|
-
[
|
|
145
|
-
[
|
|
146
|
-
[
|
|
147
|
-
[
|
|
148
|
-
[
|
|
149
|
-
[
|
|
150
|
-
[
|
|
151
|
-
[
|
|
152
|
-
[
|
|
153
|
-
[
|
|
154
|
-
[
|
|
155
|
-
[
|
|
156
|
-
[
|
|
157
|
-
[
|
|
158
|
-
[
|
|
159
|
-
[
|
|
160
|
-
[
|
|
161
|
-
[
|
|
162
|
-
[
|
|
163
|
-
[
|
|
164
|
-
[
|
|
165
|
-
[
|
|
166
|
-
[
|
|
167
|
-
[
|
|
168
|
-
[
|
|
169
|
-
[
|
|
170
|
-
[
|
|
171
|
-
[
|
|
172
|
-
[
|
|
173
|
-
[
|
|
174
|
-
[
|
|
175
|
-
[
|
|
176
|
-
[
|
|
177
|
-
[
|
|
178
|
-
[
|
|
179
|
-
[
|
|
180
|
-
[
|
|
181
|
-
[
|
|
182
|
-
[
|
|
183
|
-
[
|
|
184
|
-
[
|
|
185
|
-
[
|
|
186
|
-
[
|
|
187
|
-
[
|
|
188
|
-
[
|
|
189
|
-
[
|
|
190
|
-
[
|
|
191
|
-
[
|
|
192
|
-
[
|
|
193
|
-
[
|
|
194
|
-
[
|
|
195
|
-
[
|
|
196
|
-
[
|
|
197
|
-
[
|
|
198
|
-
[
|
|
199
|
-
[
|
|
200
|
-
[
|
|
201
|
-
[
|
|
202
|
-
[
|
|
203
|
-
[
|
|
204
|
-
[
|
|
205
|
-
[
|
|
206
|
-
[
|
|
207
|
-
[
|
|
208
|
-
[
|
|
209
|
-
[
|
|
210
|
-
[
|
|
211
|
-
[
|
|
212
|
-
[
|
|
213
|
-
[
|
|
214
|
-
[
|
|
215
|
-
[
|
|
216
|
-
[
|
|
217
|
-
[
|
|
218
|
-
[
|
|
219
|
-
[
|
|
220
|
-
[
|
|
221
|
-
[
|
|
222
|
-
[
|
|
223
|
-
[
|
|
224
|
-
[
|
|
225
|
-
[
|
|
226
|
-
[
|
|
227
|
-
[
|
|
228
|
-
[
|
|
229
|
-
[
|
|
230
|
-
[
|
|
231
|
-
[
|
|
232
|
-
[
|
|
233
|
-
[
|
|
234
|
-
[
|
|
235
|
-
[
|
|
236
|
-
[
|
|
237
|
-
[
|
|
238
|
-
[
|
|
239
|
-
[
|
|
240
|
-
[
|
|
241
|
-
[
|
|
242
|
-
[
|
|
243
|
-
[
|
|
244
|
-
[
|
|
245
|
-
[
|
|
246
|
-
[
|
|
247
|
-
[
|
|
248
|
-
[
|
|
249
|
-
[
|
|
132
|
+
export const DataTypeNames = {
|
|
133
|
+
[DataTypeOIDs.bool]: 'bool',
|
|
134
|
+
[DataTypeOIDs.bytea]: 'bytea',
|
|
135
|
+
[DataTypeOIDs.char]: 'char',
|
|
136
|
+
[DataTypeOIDs.name]: 'name',
|
|
137
|
+
[DataTypeOIDs.int8]: 'int8',
|
|
138
|
+
[DataTypeOIDs.int2]: 'int2',
|
|
139
|
+
[DataTypeOIDs.int2vector]: 'int2vector',
|
|
140
|
+
[DataTypeOIDs.int4]: 'int4',
|
|
141
|
+
[DataTypeOIDs.regproc]: 'regproc',
|
|
142
|
+
[DataTypeOIDs.text]: 'text',
|
|
143
|
+
[DataTypeOIDs.oid]: 'oid',
|
|
144
|
+
[DataTypeOIDs.tid]: 'tid',
|
|
145
|
+
[DataTypeOIDs.xid]: 'xid',
|
|
146
|
+
[DataTypeOIDs.cid]: 'cid',
|
|
147
|
+
[DataTypeOIDs.oidvector]: 'oidvector',
|
|
148
|
+
[DataTypeOIDs.json]: 'json',
|
|
149
|
+
[DataTypeOIDs.xml]: 'xml',
|
|
150
|
+
[DataTypeOIDs.point]: 'point',
|
|
151
|
+
[DataTypeOIDs.lseg]: 'lseg',
|
|
152
|
+
[DataTypeOIDs.path]: 'path',
|
|
153
|
+
[DataTypeOIDs.box]: 'box',
|
|
154
|
+
[DataTypeOIDs.polygon]: 'polygon',
|
|
155
|
+
[DataTypeOIDs.line]: 'line',
|
|
156
|
+
[DataTypeOIDs.cidr]: 'cidr',
|
|
157
|
+
[DataTypeOIDs.float4]: 'float4',
|
|
158
|
+
[DataTypeOIDs.float8]: 'float8',
|
|
159
|
+
[DataTypeOIDs.unknown]: 'unknown',
|
|
160
|
+
[DataTypeOIDs.circle]: 'circle',
|
|
161
|
+
[DataTypeOIDs.macaddr8]: 'macaddr8',
|
|
162
|
+
[DataTypeOIDs.money]: 'money',
|
|
163
|
+
[DataTypeOIDs.macaddr]: 'macaddr',
|
|
164
|
+
[DataTypeOIDs.inet]: 'inet',
|
|
165
|
+
[DataTypeOIDs.bpchar]: 'bpchar',
|
|
166
|
+
[DataTypeOIDs.varchar]: 'varchar',
|
|
167
|
+
[DataTypeOIDs.date]: 'date',
|
|
168
|
+
[DataTypeOIDs.time]: 'time',
|
|
169
|
+
[DataTypeOIDs.timestamp]: 'timestamp',
|
|
170
|
+
[DataTypeOIDs.timestamptz]: 'timestamptz',
|
|
171
|
+
[DataTypeOIDs.interval]: 'interval',
|
|
172
|
+
[DataTypeOIDs.timetz]: 'timetz',
|
|
173
|
+
[DataTypeOIDs.bit]: 'bit',
|
|
174
|
+
[DataTypeOIDs.varbit]: 'varbit',
|
|
175
|
+
[DataTypeOIDs.numeric]: 'numeric',
|
|
176
|
+
[DataTypeOIDs.refcursor]: 'refcursor',
|
|
177
|
+
[DataTypeOIDs.regprocedure]: 'regprocedure',
|
|
178
|
+
[DataTypeOIDs.regoper]: 'regoper',
|
|
179
|
+
[DataTypeOIDs.regoperator]: 'regoperator',
|
|
180
|
+
[DataTypeOIDs.regclass]: 'regclass',
|
|
181
|
+
[DataTypeOIDs.regtype]: 'regtype',
|
|
182
|
+
[DataTypeOIDs.record]: 'record',
|
|
183
|
+
[DataTypeOIDs.cstring]: 'cstring',
|
|
184
|
+
[DataTypeOIDs.any]: 'any',
|
|
185
|
+
[DataTypeOIDs.anyarray]: 'anyarray',
|
|
186
|
+
[DataTypeOIDs.void]: 'void',
|
|
187
|
+
[DataTypeOIDs.trigger]: 'trigger',
|
|
188
|
+
[DataTypeOIDs.language_handler]: 'language_handler',
|
|
189
|
+
[DataTypeOIDs.internal]: 'internal',
|
|
190
|
+
[DataTypeOIDs.anyelement]: 'anyelement',
|
|
191
|
+
[DataTypeOIDs.anynonarray]: 'anynonarray',
|
|
192
|
+
[DataTypeOIDs.uuid]: 'uuid',
|
|
193
|
+
[DataTypeOIDs.jsonb]: 'jsonb',
|
|
194
|
+
[DataTypeOIDs.anyrange]: 'anyrange',
|
|
195
|
+
[DataTypeOIDs.int4range]: 'int4range',
|
|
196
|
+
[DataTypeOIDs.numrange]: 'numrange',
|
|
197
|
+
[DataTypeOIDs.tsrange]: 'tsrange',
|
|
198
|
+
[DataTypeOIDs.rstzrange]: 'rstzrange',
|
|
199
|
+
[DataTypeOIDs.daterange]: 'daterange',
|
|
200
|
+
[DataTypeOIDs.int8range]: 'int8range',
|
|
201
|
+
[DataTypeOIDs._xml]: '_xml',
|
|
202
|
+
[DataTypeOIDs._json]: '_json',
|
|
203
|
+
[DataTypeOIDs._xid8]: '_xid8',
|
|
204
|
+
[DataTypeOIDs._line]: '_line',
|
|
205
|
+
[DataTypeOIDs._cidr]: '_cidr',
|
|
206
|
+
[DataTypeOIDs._circle]: '_circle',
|
|
207
|
+
[DataTypeOIDs._macaddr8]: '_macaddr8',
|
|
208
|
+
[DataTypeOIDs._money]: '_money',
|
|
209
|
+
[DataTypeOIDs._bool]: '_bool',
|
|
210
|
+
[DataTypeOIDs._bytea]: '_bytea',
|
|
211
|
+
[DataTypeOIDs._char]: '_char',
|
|
212
|
+
[DataTypeOIDs._name]: '_name',
|
|
213
|
+
[DataTypeOIDs._int2]: '_int2',
|
|
214
|
+
[DataTypeOIDs._int2vector]: '_int2vector',
|
|
215
|
+
[DataTypeOIDs._int4]: '_int4',
|
|
216
|
+
[DataTypeOIDs._regproc]: '_regproc',
|
|
217
|
+
[DataTypeOIDs._text]: '_text',
|
|
218
|
+
[DataTypeOIDs._tid]: '_tid',
|
|
219
|
+
[DataTypeOIDs._xid]: '_xid',
|
|
220
|
+
[DataTypeOIDs._cid]: '_cid',
|
|
221
|
+
[DataTypeOIDs._oidvector]: '_oidvector',
|
|
222
|
+
[DataTypeOIDs._bpchar]: '_bpchar',
|
|
223
|
+
[DataTypeOIDs._varchar]: '_varchar',
|
|
224
|
+
[DataTypeOIDs._int8]: '_int8',
|
|
225
|
+
[DataTypeOIDs._point]: '_point',
|
|
226
|
+
[DataTypeOIDs._lseg]: '_lseg',
|
|
227
|
+
[DataTypeOIDs._path]: '_path',
|
|
228
|
+
[DataTypeOIDs._box]: '_box',
|
|
229
|
+
[DataTypeOIDs._float4]: '_float4',
|
|
230
|
+
[DataTypeOIDs._float8]: '_float8',
|
|
231
|
+
[DataTypeOIDs._polygon]: '_polygon',
|
|
232
|
+
[DataTypeOIDs._oid]: '_oid',
|
|
233
|
+
[DataTypeOIDs._macaddr]: '_macaddr',
|
|
234
|
+
[DataTypeOIDs._inet]: '_inet',
|
|
235
|
+
[DataTypeOIDs._timestamp]: '_timestamp',
|
|
236
|
+
[DataTypeOIDs._date]: '_date',
|
|
237
|
+
[DataTypeOIDs._time]: '_time',
|
|
238
|
+
[DataTypeOIDs._timestamptz]: '_timestamptz',
|
|
239
|
+
[DataTypeOIDs._interval]: '_interval',
|
|
240
|
+
[DataTypeOIDs._numeric]: '_numeric',
|
|
241
|
+
[DataTypeOIDs._cstring]: '_cstring',
|
|
242
|
+
[DataTypeOIDs._timetz]: '_timetz',
|
|
243
|
+
[DataTypeOIDs._bit]: '_bit',
|
|
244
|
+
[DataTypeOIDs._varbit]: '_varbit',
|
|
245
|
+
[DataTypeOIDs._uuid]: '_uuid',
|
|
246
|
+
[DataTypeOIDs._jsonb]: '_jsonb',
|
|
250
247
|
};
|
package/esm/data-type-map.js
CHANGED
|
@@ -1,31 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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 {
|
|
1
|
+
import { DataTypeOIDs } from './constants.js';
|
|
2
|
+
import { ArrayBoolType, BoolType } from './data-types/bool-type.js';
|
|
3
|
+
import { ArrayBoxType, BoxType } from './data-types/box-type.js';
|
|
4
|
+
import { ArrayByteaType, ByteaType } from './data-types/bytea-type.js';
|
|
5
|
+
import { ArrayCharType, CharType } from './data-types/char-type.js';
|
|
6
|
+
import { ArrayCircleType, CircleType } from './data-types/circle-type.js';
|
|
7
|
+
import { ArrayDateType, DateType } from './data-types/date-type.js';
|
|
8
|
+
import { ArrayFloat4Type, Float4Type } from './data-types/float4-type.js';
|
|
9
|
+
import { ArrayFloat8Type, Float8Type } from './data-types/float8-type.js';
|
|
10
|
+
import { ArrayInt2Type, Int2Type } from './data-types/int2-type.js';
|
|
11
|
+
import { ArrayInt2VectorType, Int2VectorType } from './data-types/int2-vector-type.js';
|
|
12
|
+
import { ArrayInt4Type, Int4Type } from './data-types/int4-type.js';
|
|
13
|
+
import { ArrayInt8Type, Int8Type } from './data-types/int8-type.js';
|
|
14
|
+
import { ArrayJsonType, JsonType } from './data-types/json-type.js';
|
|
15
|
+
import { ArrayJsonbType, JsonbType } from './data-types/jsonb-type.js';
|
|
16
|
+
import { ArrayLsegType, LsegType } from './data-types/lseg-type.js';
|
|
17
|
+
import { ArrayNumericType, NumericType } from './data-types/numeric-type.js';
|
|
18
|
+
import { ArrayOidType, OidType, VectorOidType } from './data-types/oid-type.js';
|
|
19
|
+
import { ArrayPointType, PointType } from './data-types/point-type.js';
|
|
20
|
+
import { ArrayTimeType, TimeType } from './data-types/time-type.js';
|
|
21
|
+
import { ArrayTimestampType, TimestampType } from './data-types/timestamp-type.js';
|
|
22
|
+
import { ArrayTimestamptzType, TimestamptzType } from './data-types/timestamptz-type.js';
|
|
23
|
+
import { ArrayUuidType, UuidType } from './data-types/uuid-type.js';
|
|
24
|
+
import { ArrayVarcharType, VarcharType } from './data-types/varchar-type.js';
|
|
25
|
+
export class DataTypeMap {
|
|
29
26
|
constructor(other) {
|
|
30
27
|
this._itemsByOID = {};
|
|
31
28
|
this._items = [];
|
|
@@ -48,7 +45,7 @@ class DataTypeMap {
|
|
|
48
45
|
}
|
|
49
46
|
determine(value) {
|
|
50
47
|
if (value == null)
|
|
51
|
-
return
|
|
48
|
+
return DataTypeOIDs.unknown;
|
|
52
49
|
const valueIsArray = Array.isArray(value);
|
|
53
50
|
let i;
|
|
54
51
|
let t;
|
|
@@ -61,59 +58,58 @@ class DataTypeMap {
|
|
|
61
58
|
else if (!t.elementsOID && t.isType(value))
|
|
62
59
|
return t.oid;
|
|
63
60
|
}
|
|
64
|
-
return
|
|
61
|
+
return DataTypeOIDs.unknown;
|
|
65
62
|
}
|
|
66
63
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
...varchar_type_js_1.ArrayVarcharType,
|
|
64
|
+
export const GlobalTypeMap = new DataTypeMap();
|
|
65
|
+
GlobalTypeMap.register([OidType, VectorOidType, ArrayOidType]);
|
|
66
|
+
GlobalTypeMap.register([JsonbType, ArrayJsonbType]);
|
|
67
|
+
GlobalTypeMap.register([JsonType, ArrayJsonType]);
|
|
68
|
+
GlobalTypeMap.register([BoolType, ArrayBoolType]);
|
|
69
|
+
GlobalTypeMap.register([NumericType, ArrayNumericType]);
|
|
70
|
+
GlobalTypeMap.register([Float4Type, ArrayFloat4Type]);
|
|
71
|
+
GlobalTypeMap.register([Float8Type, ArrayFloat8Type]);
|
|
72
|
+
GlobalTypeMap.register([Int2Type, ArrayInt2Type]);
|
|
73
|
+
GlobalTypeMap.register([Int4Type, ArrayInt4Type]);
|
|
74
|
+
GlobalTypeMap.register([Int8Type, ArrayInt8Type]);
|
|
75
|
+
GlobalTypeMap.register([ByteaType, ArrayByteaType]);
|
|
76
|
+
GlobalTypeMap.register([CircleType, ArrayCircleType]);
|
|
77
|
+
GlobalTypeMap.register([PointType, ArrayPointType]);
|
|
78
|
+
GlobalTypeMap.register([LsegType, ArrayLsegType]);
|
|
79
|
+
GlobalTypeMap.register([BoxType, ArrayBoxType]);
|
|
80
|
+
GlobalTypeMap.register([Int2VectorType, ArrayInt2VectorType]);
|
|
81
|
+
GlobalTypeMap.register({ ...VarcharType, name: 'bpchar', oid: DataTypeOIDs.bpchar });
|
|
82
|
+
GlobalTypeMap.register({
|
|
83
|
+
...ArrayVarcharType,
|
|
88
84
|
name: '_bpchar',
|
|
89
|
-
oid:
|
|
90
|
-
elementsOID:
|
|
85
|
+
oid: DataTypeOIDs._bpchar,
|
|
86
|
+
elementsOID: DataTypeOIDs.bpchar,
|
|
91
87
|
});
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
...
|
|
88
|
+
GlobalTypeMap.register({ ...VarcharType, name: 'name', oid: DataTypeOIDs.name });
|
|
89
|
+
GlobalTypeMap.register({
|
|
90
|
+
...ArrayVarcharType,
|
|
95
91
|
name: '_name',
|
|
96
|
-
oid:
|
|
97
|
-
elementsOID:
|
|
92
|
+
oid: DataTypeOIDs._name,
|
|
93
|
+
elementsOID: DataTypeOIDs.name,
|
|
98
94
|
});
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
...
|
|
95
|
+
GlobalTypeMap.register({ ...VarcharType, name: 'text', oid: DataTypeOIDs.text });
|
|
96
|
+
GlobalTypeMap.register({
|
|
97
|
+
...ArrayVarcharType,
|
|
102
98
|
name: '_text',
|
|
103
|
-
oid:
|
|
104
|
-
elementsOID:
|
|
99
|
+
oid: DataTypeOIDs._text,
|
|
100
|
+
elementsOID: DataTypeOIDs.text,
|
|
105
101
|
});
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
...
|
|
102
|
+
GlobalTypeMap.register({ ...VarcharType, name: 'xml', oid: DataTypeOIDs.xml });
|
|
103
|
+
GlobalTypeMap.register({
|
|
104
|
+
...ArrayVarcharType,
|
|
109
105
|
name: '_xml',
|
|
110
|
-
oid:
|
|
111
|
-
elementsOID:
|
|
106
|
+
oid: DataTypeOIDs._xml,
|
|
107
|
+
elementsOID: DataTypeOIDs.xml,
|
|
112
108
|
});
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
109
|
+
GlobalTypeMap.register([VarcharType, ArrayVarcharType]);
|
|
110
|
+
GlobalTypeMap.register([UuidType, ArrayUuidType]);
|
|
111
|
+
GlobalTypeMap.register([CharType, ArrayCharType]);
|
|
112
|
+
GlobalTypeMap.register([TimestamptzType, ArrayTimestamptzType]);
|
|
113
|
+
GlobalTypeMap.register([TimeType, ArrayTimeType]);
|
|
114
|
+
GlobalTypeMap.register([DateType, ArrayDateType]);
|
|
115
|
+
GlobalTypeMap.register([TimestampType, ArrayTimestampType]);
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ArrayBoolType = exports.BoolType = void 0;
|
|
4
|
-
const constants_js_1 = require("../constants.js");
|
|
5
|
-
exports.BoolType = {
|
|
1
|
+
import { DataTypeOIDs } from '../constants.js';
|
|
2
|
+
export const BoolType = {
|
|
6
3
|
name: 'bool',
|
|
7
|
-
oid:
|
|
4
|
+
oid: DataTypeOIDs.bool,
|
|
8
5
|
jsType: 'boolean',
|
|
9
6
|
parseBinary(v) {
|
|
10
7
|
return !!v.readUInt8();
|
|
@@ -19,9 +16,9 @@ exports.BoolType = {
|
|
|
19
16
|
return typeof v === 'boolean';
|
|
20
17
|
},
|
|
21
18
|
};
|
|
22
|
-
|
|
23
|
-
...
|
|
19
|
+
export const ArrayBoolType = {
|
|
20
|
+
...BoolType,
|
|
24
21
|
name: '_bool',
|
|
25
|
-
oid:
|
|
26
|
-
elementsOID:
|
|
22
|
+
oid: DataTypeOIDs._bool,
|
|
23
|
+
elementsOID: DataTypeOIDs.bool,
|
|
27
24
|
};
|