postgrejs 3.11.1 → 3.12.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/connection/bind-param.d.ts +21 -0
- package/connection/bind-param.js +21 -0
- package/connection/connection.d.ts +136 -0
- package/connection/connection.js +132 -5
- package/connection/copy-stream.d.ts +2 -0
- package/connection/copy-stream.js +2 -0
- package/connection/cursor.d.ts +67 -5
- package/connection/cursor.js +88 -15
- package/connection/intl-connection.d.ts +22 -0
- package/connection/intl-connection.js +107 -17
- package/connection/large-object.d.ts +18 -0
- package/connection/large-object.js +17 -0
- package/connection/logical-replication.d.ts +15 -0
- package/connection/logical-replication.js +6 -0
- package/connection/pool.d.ts +80 -0
- package/connection/pool.js +82 -9
- package/connection/portal.d.ts +37 -0
- package/connection/portal.js +29 -0
- package/connection/prepared-statement.d.ts +109 -0
- package/connection/prepared-statement.js +150 -7
- package/constants.d.ts +18 -0
- package/constants.js +18 -0
- package/data-type-map.d.ts +38 -0
- package/data-type-map.js +38 -0
- package/data-types/bit-type.d.ts +4 -0
- package/data-types/bit-type.js +4 -0
- package/data-types/bool-type.d.ts +2 -0
- package/data-types/bool-type.js +2 -0
- package/data-types/box-type.d.ts +2 -0
- package/data-types/box-type.js +2 -0
- package/data-types/bytea-type.d.ts +2 -0
- package/data-types/bytea-type.js +2 -0
- package/data-types/char-type.d.ts +2 -0
- package/data-types/char-type.js +2 -0
- package/data-types/circle-type.d.ts +2 -0
- package/data-types/circle-type.js +2 -0
- package/data-types/date-type.d.ts +2 -0
- package/data-types/date-type.js +2 -0
- package/data-types/float4-type.d.ts +2 -0
- package/data-types/float4-type.js +2 -0
- package/data-types/float8-type.d.ts +2 -0
- package/data-types/float8-type.js +2 -0
- package/data-types/inet-type.d.ts +4 -0
- package/data-types/inet-type.js +4 -0
- package/data-types/int2-type.d.ts +2 -0
- package/data-types/int2-type.js +3 -1
- package/data-types/int2-vector-type.d.ts +2 -0
- package/data-types/int2-vector-type.js +2 -0
- package/data-types/int4-type.d.ts +2 -0
- package/data-types/int4-type.js +3 -1
- package/data-types/int8-type.d.ts +2 -0
- package/data-types/int8-type.js +4 -2
- package/data-types/interval-type.d.ts +9 -0
- package/data-types/interval-type.js +9 -0
- package/data-types/json-type.d.ts +2 -0
- package/data-types/json-type.js +2 -0
- package/data-types/jsonb-type.d.ts +2 -0
- package/data-types/jsonb-type.js +2 -0
- package/data-types/jsonpath-type.d.ts +2 -0
- package/data-types/jsonpath-type.js +2 -0
- package/data-types/line-type.d.ts +2 -0
- package/data-types/line-type.js +2 -0
- package/data-types/lseg-type.d.ts +2 -0
- package/data-types/lseg-type.js +2 -0
- package/data-types/macaddr-type.d.ts +4 -0
- package/data-types/macaddr-type.js +4 -0
- package/data-types/money-type.d.ts +1 -0
- package/data-types/money-type.js +17 -10
- package/data-types/numeric-type.d.ts +2 -0
- package/data-types/numeric-type.js +2 -0
- package/data-types/oid-type.d.ts +2 -0
- package/data-types/oid-type.js +3 -1
- package/data-types/oid-vector-type.d.ts +1 -0
- package/data-types/oid-vector-type.js +1 -0
- package/data-types/path-type.d.ts +4 -0
- package/data-types/path-type.js +4 -0
- package/data-types/pg-lsn-type.d.ts +2 -0
- package/data-types/pg-lsn-type.js +2 -0
- package/data-types/point-type.d.ts +2 -0
- package/data-types/point-type.js +2 -0
- package/data-types/range-type.d.ts +4 -0
- package/data-types/range-type.js +4 -0
- package/data-types/snapshot-type.d.ts +4 -0
- package/data-types/snapshot-type.js +4 -0
- package/data-types/tid-type.d.ts +2 -0
- package/data-types/tid-type.js +2 -0
- package/data-types/time-type.d.ts +2 -0
- package/data-types/time-type.js +2 -0
- package/data-types/timestamp-type.d.ts +2 -0
- package/data-types/timestamp-type.js +2 -0
- package/data-types/timestamptz-type.d.ts +2 -0
- package/data-types/timestamptz-type.js +2 -0
- package/data-types/timetz-type.d.ts +2 -0
- package/data-types/timetz-type.js +2 -0
- package/data-types/tsvector-type.d.ts +4 -0
- package/data-types/tsvector-type.js +4 -0
- package/data-types/uuid-type.d.ts +2 -0
- package/data-types/uuid-type.js +2 -0
- package/data-types/varchar-type.d.ts +2 -0
- package/data-types/varchar-type.js +2 -0
- package/data-types/xid-type.d.ts +6 -0
- package/data-types/xid-type.js +8 -1
- package/interfaces/command-result.d.ts +7 -0
- package/interfaces/copy-from-rows-options.d.ts +4 -0
- package/interfaces/data-mapping-options.d.ts +6 -0
- package/interfaces/data-type.d.ts +37 -0
- package/interfaces/database-connection-params.d.ts +31 -0
- package/interfaces/field-info.d.ts +8 -0
- package/interfaces/function-call-options.d.ts +1 -0
- package/interfaces/function-call-result.d.ts +6 -0
- package/interfaces/pipeline-request.d.ts +2 -0
- package/interfaces/query-options.d.ts +7 -0
- package/interfaces/query-result.d.ts +7 -0
- package/interfaces/script-execute-options.d.ts +4 -0
- package/interfaces/script-result.d.ts +1 -0
- package/interfaces/statement-prepare-options.d.ts +1 -0
- package/package.json +5 -5
- package/protocol/backend.d.ts +6 -0
- package/protocol/backend.js +35 -5
- package/protocol/cert-signature.d.ts +8 -0
- package/protocol/cert-signature.js +8 -0
- package/protocol/database-error.d.ts +8 -0
- package/protocol/database-error.js +8 -0
- package/protocol/frontend.d.ts +16 -0
- package/protocol/frontend.js +13 -6
- package/protocol/pg-socket.d.ts +10 -0
- package/protocol/pg-socket.js +14 -7
- package/protocol/pgoutput.d.ts +15 -0
- package/protocol/pgoutput.js +7 -0
- package/protocol/protocol.d.ts +50 -2
- package/protocol/protocol.js +17 -1
- package/protocol/sasl.d.ts +22 -0
- package/protocol/sasl.js +21 -0
- package/protocol/smart-buffer.d.ts +4 -0
- package/safe-event-emitter.d.ts +7 -0
- package/safe-event-emitter.js +7 -0
- package/types.d.ts +21 -0
- package/util/array-calculatedim.d.ts +10 -0
- package/util/array-calculatedim.js +10 -0
- package/util/assert-integer.d.ts +40 -25
- package/util/assert-integer.js +97 -32
- package/util/bigint-methods.d.ts +7 -0
- package/util/bigint-methods.js +9 -0
- package/util/config-from-env.d.ts +10 -0
- package/util/config-from-env.js +10 -0
- package/util/connection-config.d.ts +17 -0
- package/util/connection-config.js +17 -0
- package/util/copy-from-rows.d.ts +12 -0
- package/util/copy-from-rows.js +9 -0
- package/util/decimal-as-string.d.ts +6 -0
- package/util/decimal-as-string.js +6 -0
- package/util/decode-binaryarray.d.ts +9 -0
- package/util/decode-binaryarray.js +9 -0
- package/util/escape-literal.d.ts +11 -0
- package/util/escape-literal.js +13 -0
- package/util/fast-parseint.d.ts +14 -0
- package/util/fast-parseint.js +14 -0
- package/util/format-datetime.d.ts +26 -0
- package/util/format-datetime.js +26 -0
- package/util/get-parsers.d.ts +9 -0
- package/util/get-parsers.js +9 -0
- package/util/hex-text.d.ts +13 -21
- package/util/hex-text.js +24 -21
- package/util/local-date.d.ts +2 -41
- package/util/local-date.js +39 -41
- package/util/parse-array.d.ts +8 -0
- package/util/parse-array.js +8 -0
- package/util/parse-bytea.d.ts +15 -0
- package/util/parse-bytea.js +15 -0
- package/util/parse-datetime.d.ts +26 -0
- package/util/parse-datetime.js +26 -0
- package/util/parse-row.d.ts +23 -2
- package/util/parse-row.js +56 -36
- package/util/parse-time.d.ts +10 -0
- package/util/parse-time.js +10 -0
- package/util/resolve-column-formats.d.ts +1 -0
- package/util/row-decoder.d.ts +32 -0
- package/util/row-decoder.js +22 -0
- package/util/stringify-arrayliteral.d.ts +33 -0
- package/util/stringify-arrayliteral.js +242 -7
- package/util/stringify-for-sql.d.ts +17 -0
- package/util/stringify-for-sql.js +17 -0
- package/util/unspecified-param.d.ts +26 -2
- package/util/unspecified-param.js +26 -2
- package/util/wrap-row-description.d.ts +10 -0
- package/util/wrap-row-description.js +10 -0
- package/CHANGELOG.md +0 -1426
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataTypeOIDs } from '../constants.js';
|
|
1
|
+
import { DataTypeNames, DataTypeOIDs } from '../constants.js';
|
|
2
2
|
import { GlobalTypeMap } from '../data-type-map.js';
|
|
3
3
|
import { Protocol } from '../protocol/protocol.js';
|
|
4
4
|
import { SafeEventEmitter } from '../safe-event-emitter.js';
|
|
@@ -8,20 +8,54 @@ import { resolveColumnFormats } from '../util/resolve-column-formats.js';
|
|
|
8
8
|
import { resolveRowType } from '../util/row-decoder.js';
|
|
9
9
|
import { isTransactionCommand, refusesSavepoint, } from '../util/transaction-command.js';
|
|
10
10
|
import { wrapRowDescription } from '../util/wrap-row-description.js';
|
|
11
|
+
import { BindParam } from './bind-param.js';
|
|
11
12
|
import { Cursor } from './cursor.js';
|
|
12
13
|
import { getIntlConnection } from './intl-connection.js';
|
|
13
14
|
import { Portal } from './portal.js';
|
|
14
15
|
let statementCounter = 0;
|
|
15
16
|
let portalCounter = 0;
|
|
17
|
+
/**
|
|
18
|
+
* A statement parsed once by the server and executed as many times as
|
|
19
|
+
* the caller likes.
|
|
20
|
+
*
|
|
21
|
+
* Obtained from `Connection.prepare()` or `Pool.prepare()`. Each
|
|
22
|
+
* `execute()` then costs a Bind and an Execute instead of a full Parse,
|
|
23
|
+
* and the server plans it once - which is what makes it worth naming a
|
|
24
|
+
* statement that runs in a loop. `executeBatch()` goes further and sends
|
|
25
|
+
* every parameter set before waiting for any of them.
|
|
26
|
+
*
|
|
27
|
+
* ```ts
|
|
28
|
+
* const statement = await connection.prepare(
|
|
29
|
+
* 'update customers set city = $1 where id = $2',
|
|
30
|
+
* );
|
|
31
|
+
* await statement.execute({ params: ['Berlin', 1] });
|
|
32
|
+
* await statement.execute({ params: ['Paris', 2] });
|
|
33
|
+
* await statement.close();
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* A statement holds a server-side name until `close()`, and one taken
|
|
37
|
+
* from a `Pool` holds that pool's connection with it, so it must be
|
|
38
|
+
* closed - `await using` does it at the end of the scope.
|
|
39
|
+
*
|
|
40
|
+
* Emits `close` and `notice`.
|
|
41
|
+
*/
|
|
16
42
|
export class PreparedStatement extends SafeEventEmitter {
|
|
17
43
|
_connection;
|
|
18
44
|
_sql = '';
|
|
19
45
|
_name = '';
|
|
20
46
|
_paramTypes;
|
|
47
|
+
_resolvedParamTypes;
|
|
21
48
|
_fields;
|
|
22
49
|
_onErrorSavePoint;
|
|
23
50
|
_refCount = 0;
|
|
24
51
|
_closed = false;
|
|
52
|
+
/**
|
|
53
|
+
* Builds the handle; `prepare()` is what sends anything.
|
|
54
|
+
*
|
|
55
|
+
* @param connection The connection this statement lives on.
|
|
56
|
+
* @param sql The statement text.
|
|
57
|
+
* @param paramTypes Declared parameter types, if the caller named any.
|
|
58
|
+
*/
|
|
25
59
|
constructor(connection, sql, paramTypes) {
|
|
26
60
|
super();
|
|
27
61
|
this._connection = connection;
|
|
@@ -30,31 +64,82 @@ export class PreparedStatement extends SafeEventEmitter {
|
|
|
30
64
|
this._paramTypes = paramTypes;
|
|
31
65
|
this._onErrorSavePoint = 'SP_' + Math.round(Math.random() * 100000000);
|
|
32
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Parses the statement on the server and describes it, in one round
|
|
69
|
+
* trip, so the first `execute()` already knows what its columns are.
|
|
70
|
+
*
|
|
71
|
+
* `Connection.prepare()` is the way to call this.
|
|
72
|
+
*
|
|
73
|
+
* @param connection The connection to prepare on.
|
|
74
|
+
* @param sql The statement text.
|
|
75
|
+
* @param options Declared parameter types.
|
|
76
|
+
* @returns The prepared statement.
|
|
77
|
+
* @throws DatabaseError When the server refuses to parse it.
|
|
78
|
+
*/
|
|
33
79
|
static async prepare(connection, sql, options) {
|
|
34
80
|
const intoCon = getIntlConnection(connection);
|
|
35
81
|
intoCon.assertConnected();
|
|
36
82
|
const statement = new PreparedStatement(connection, sql, options?.paramTypes);
|
|
37
|
-
const { fields } = await intoCon.prepareOnce(sql, statement.paramTypes, statement.name);
|
|
83
|
+
const { fields, resolvedParamTypes } = await intoCon.prepareOnce(sql, statement.paramTypes, statement.name);
|
|
38
84
|
statement._fields = fields;
|
|
85
|
+
statement._resolvedParamTypes = resolvedParamTypes;
|
|
39
86
|
statement._refCount = 1;
|
|
40
87
|
return statement;
|
|
41
88
|
}
|
|
89
|
+
/** The connection this statement was prepared on. */
|
|
42
90
|
get connection() {
|
|
43
91
|
return this._connection;
|
|
44
92
|
}
|
|
93
|
+
/** The name the server knows this statement by. */
|
|
45
94
|
get name() {
|
|
46
95
|
return this._name;
|
|
47
96
|
}
|
|
97
|
+
/** The statement text, as it was prepared. */
|
|
48
98
|
get sql() {
|
|
49
99
|
return this._sql;
|
|
50
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* The parameter types the caller declared at `prepare()`, if any -
|
|
103
|
+
* `resolvedParamTypes` is what the server made of them.
|
|
104
|
+
*/
|
|
51
105
|
get paramTypes() {
|
|
52
106
|
return this._paramTypes;
|
|
53
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* What the server made of each parameter, in order, as its Describe
|
|
110
|
+
* answered - not what was asked for in `paramTypes`.
|
|
111
|
+
*
|
|
112
|
+
* A parameter the caller declared nothing for is resolved by the
|
|
113
|
+
* server from where it appears: the column it is inserted into, the
|
|
114
|
+
* operator it sits beside, the function it is passed to. It never
|
|
115
|
+
* looks at the value, which is still three messages away, so this is
|
|
116
|
+
* a property of the statement and does not change between executions.
|
|
117
|
+
*
|
|
118
|
+
* Useful for two things. It says what a parameter with no context
|
|
119
|
+
* became - `select $1` resolves to `text`, which is why an array
|
|
120
|
+
* there comes back as an array literal rather than an array. And it
|
|
121
|
+
* is the type to name with `new BindParam(oid, v)` for a caller who
|
|
122
|
+
* wants the binary encoding a large numeric array gives up by going
|
|
123
|
+
* out untyped (see `isUnspecifiedParam`).
|
|
124
|
+
*/
|
|
125
|
+
get resolvedParamTypes() {
|
|
126
|
+
return this._resolvedParamTypes;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Runs the statement once, with one set of parameters.
|
|
130
|
+
*
|
|
131
|
+
* Takes the same options `Connection.query()` does, minus the SQL -
|
|
132
|
+
* parameters, row shape, type mapping, `cursor`, a signal.
|
|
133
|
+
*
|
|
134
|
+
* @param options Parameters and how to read the result.
|
|
135
|
+
* @returns The rows, the command tag, and what the columns were.
|
|
136
|
+
* @throws DatabaseError When the server refuses the execution.
|
|
137
|
+
*/
|
|
138
|
+
/* The options are merged with the connection's defaults here rather
|
|
139
|
+
than deeper down, because a cursor keeps them and decodes its own
|
|
140
|
+
rows with them long after this call is over. */
|
|
54
141
|
async execute(options = {}) {
|
|
55
142
|
const intlCon = getIntlConnection(this.connection);
|
|
56
|
-
// Folded in here rather than deeper: a cursor keeps these options
|
|
57
|
-
// and decodes its own rows with them long after this call is over.
|
|
58
143
|
options = intlCon.withDefaults(options);
|
|
59
144
|
if (options.signal)
|
|
60
145
|
return withAbortSignal(options.signal, () => intlCon.cancel(), () => this._executeWithTransaction(options));
|
|
@@ -130,13 +215,58 @@ export class PreparedStatement extends SafeEventEmitter {
|
|
|
130
215
|
* holding a `Connection` never saw. Hard to provoke - `DEALLOCATE`
|
|
131
216
|
* does not normally raise one - which is why there is no test for it.
|
|
132
217
|
*/
|
|
218
|
+
/**
|
|
219
|
+
* Takes the value out of a `BindParam`, and refuses one that names a
|
|
220
|
+
* type this statement is not.
|
|
221
|
+
*
|
|
222
|
+
* A prepared statement's parameter types are fixed by its Parse, so a
|
|
223
|
+
* `BindParam` here cannot change one: the Bind's format code says
|
|
224
|
+
* binary or text, and the server decodes with the type it already
|
|
225
|
+
* resolved. Naming a different one and being believed would read the
|
|
226
|
+
* bytes as something else - which is why the mismatch is an error
|
|
227
|
+
* rather than something to quietly honour.
|
|
228
|
+
*
|
|
229
|
+
* It used to be neither: nothing unwrapped the object, so it reached
|
|
230
|
+
* the encoder as a value with no type of its own and went out as
|
|
231
|
+
* `'' + v`. A text column took `"[object Object]"` and said nothing.
|
|
232
|
+
*
|
|
233
|
+
* What it is compared against is what the caller declared at
|
|
234
|
+
* `prepare()`, or failing that what the server resolved - which is the
|
|
235
|
+
* same type either way, and is why an agreeing `BindParam` is simply
|
|
236
|
+
* unwrapped. Where there is nothing to compare against, the value is
|
|
237
|
+
* taken as given.
|
|
238
|
+
*/
|
|
239
|
+
_unwrapBindParams(params) {
|
|
240
|
+
if (!params)
|
|
241
|
+
return params;
|
|
242
|
+
let out;
|
|
243
|
+
const l = params.length;
|
|
244
|
+
let i;
|
|
245
|
+
let prm;
|
|
246
|
+
let expected;
|
|
247
|
+
for (i = 0; i < l; i++) {
|
|
248
|
+
prm = params[i];
|
|
249
|
+
if (!(prm instanceof BindParam))
|
|
250
|
+
continue;
|
|
251
|
+
expected = this._paramTypes?.[i] ?? this._resolvedParamTypes?.[i];
|
|
252
|
+
if (expected != null && prm.oid !== expected)
|
|
253
|
+
throw new TypeError(`Parameter $${i + 1} was given as ${typeLabel(prm.oid)}, but this ` +
|
|
254
|
+
`prepared statement's $${i + 1} is ${typeLabel(expected)}. A ` +
|
|
255
|
+
'prepared statement takes its parameter types at ' +
|
|
256
|
+
'prepare(sql, { paramTypes }), and they cannot be changed per ' +
|
|
257
|
+
'execution.');
|
|
258
|
+
out = out || params.slice();
|
|
259
|
+
out[i] = prm.value;
|
|
260
|
+
}
|
|
261
|
+
return out || params;
|
|
262
|
+
}
|
|
133
263
|
_emitNotice(msg) {
|
|
134
264
|
this.emit('notice', msg);
|
|
135
265
|
getIntlConnection(this.connection).emit('notice', msg);
|
|
136
266
|
}
|
|
137
267
|
_executeBatchWithTransaction(paramSets, options) {
|
|
138
268
|
const intlCon = getIntlConnection(this.connection);
|
|
139
|
-
return this._withTransaction(options, () => intlCon.executeBatchReused(this.name, this._fields, this.paramTypes, paramSets, options));
|
|
269
|
+
return this._withTransaction(options, () => intlCon.executeBatchReused(this.name, this._fields, this.paramTypes, paramSets.map(set => this._unwrapBindParams(set)), options));
|
|
140
270
|
}
|
|
141
271
|
async _executeWithTransaction(options = {}) {
|
|
142
272
|
// The Bind+Execute+Sync path can carry the rollbackOnError savepoint
|
|
@@ -219,6 +349,13 @@ export class PreparedStatement extends SafeEventEmitter {
|
|
|
219
349
|
throw e;
|
|
220
350
|
}
|
|
221
351
|
}
|
|
352
|
+
/**
|
|
353
|
+
* Closes the statement on the server and releases what it was holding
|
|
354
|
+
* - the connection too, when it came from a pool.
|
|
355
|
+
*
|
|
356
|
+
* Idempotent, and deferred while a cursor of this statement is still
|
|
357
|
+
* open. Emits `close`.
|
|
358
|
+
*/
|
|
222
359
|
async close() {
|
|
223
360
|
if (this._closed)
|
|
224
361
|
return;
|
|
@@ -238,6 +375,7 @@ export class PreparedStatement extends SafeEventEmitter {
|
|
|
238
375
|
}
|
|
239
376
|
async _execute(options = {}, savepoint) {
|
|
240
377
|
const intlCon = getIntlConnection(this.connection);
|
|
378
|
+
const params = this._unwrapBindParams(options.params);
|
|
241
379
|
if (options.cursor && this._fields) {
|
|
242
380
|
intlCon.ref();
|
|
243
381
|
let portal = new Portal(this, 'P_' + ++portalCounter);
|
|
@@ -247,7 +385,7 @@ export class PreparedStatement extends SafeEventEmitter {
|
|
|
247
385
|
// codes on the Bind below with no round trip of its own.
|
|
248
386
|
const typeMap = options.typeMap || GlobalTypeMap;
|
|
249
387
|
const columnFormat = resolveColumnFormats(this._fields, options, typeMap);
|
|
250
|
-
const fields = await portal.bindAndRetrieveFields(
|
|
388
|
+
const fields = await portal.bindAndRetrieveFields(params, options, columnFormat);
|
|
251
389
|
const parsers = getParsers(typeMap, fields, options);
|
|
252
390
|
const resultFields = wrapRowDescription(typeMap, fields, columnFormat, options);
|
|
253
391
|
const result = {
|
|
@@ -270,7 +408,7 @@ export class PreparedStatement extends SafeEventEmitter {
|
|
|
270
408
|
// unnamed portal, reusing the RowDescription prepare() already fetched
|
|
271
409
|
// instead of re-Describing (and re-Close-ing) a fresh named portal on
|
|
272
410
|
// every call.
|
|
273
|
-
return intlCon.executeReused(this.name, this._fields, this.paramTypes,
|
|
411
|
+
return intlCon.executeReused(this.name, this._fields, this.paramTypes, params, options, savepoint);
|
|
274
412
|
}
|
|
275
413
|
/**
|
|
276
414
|
* Called by Cursor.close() instead of separately awaiting
|
|
@@ -372,3 +510,8 @@ export class PreparedStatement extends SafeEventEmitter {
|
|
|
372
510
|
return this.close();
|
|
373
511
|
}
|
|
374
512
|
}
|
|
513
|
+
/** `int2 (21)` - the name when there is one, and always the oid. */
|
|
514
|
+
function typeLabel(oid) {
|
|
515
|
+
const name = DataTypeNames[oid];
|
|
516
|
+
return name ? `${name} (${oid})` : String(oid);
|
|
517
|
+
}
|
package/constants.d.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { Protocol } from './protocol/protocol.js';
|
|
2
2
|
import DataFormat = Protocol.DataFormat;
|
|
3
|
+
export declare const version = "3.12.1";
|
|
3
4
|
export { DataFormat };
|
|
5
|
+
/**
|
|
6
|
+
* What columns come back in unless something asks otherwise.
|
|
7
|
+
*
|
|
8
|
+
* Binary: fewer bytes on the wire and no text to parse for most types.
|
|
9
|
+
* A column named by `fetchAsString`, and the types that have no binary
|
|
10
|
+
* decoder, come back as text regardless.
|
|
11
|
+
*/
|
|
4
12
|
export declare const DEFAULT_COLUMN_FORMAT = DataFormat.binary;
|
|
13
|
+
/** Where a connection is between `connect()` and `close()`. */
|
|
5
14
|
export declare enum ConnectionState {
|
|
6
15
|
CLOSED = 0,
|
|
7
16
|
CONNECTING = 1,
|
|
@@ -9,6 +18,14 @@ export declare enum ConnectionState {
|
|
|
9
18
|
READY = 2,
|
|
10
19
|
CLOSING = 10
|
|
11
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Every type this client knows, by name, as `pg_type.oid` gives it - the
|
|
23
|
+
* scalar types and their array counterparts, which are named with a
|
|
24
|
+
* leading underscore the way the catalog names them.
|
|
25
|
+
*
|
|
26
|
+
* These are the numbers `BindParam`, `fetchAsString` and a
|
|
27
|
+
* `DataTypeMap`'s own registrations are written with.
|
|
28
|
+
*/
|
|
12
29
|
export declare const DataTypeOIDs: {
|
|
13
30
|
bool: number;
|
|
14
31
|
bytea: number;
|
|
@@ -185,4 +202,5 @@ export declare const DataTypeOIDs: {
|
|
|
185
202
|
_datemultirange: number;
|
|
186
203
|
_int8multirange: number;
|
|
187
204
|
};
|
|
205
|
+
/** The name of each type by its OID, for reporting a column's type back to a caller. */
|
|
188
206
|
export declare const DataTypeNames: Record<string, string>;
|
package/constants.js
CHANGED
|
@@ -2,8 +2,17 @@ import { Protocol } from './protocol/protocol.js';
|
|
|
2
2
|
var DataFormat = Protocol.DataFormat;
|
|
3
3
|
// @ts-ignore
|
|
4
4
|
Symbol.asyncDispose ??= Symbol('Symbol.asyncDispose');
|
|
5
|
+
export const version = '3.12.1';
|
|
5
6
|
export { DataFormat };
|
|
7
|
+
/**
|
|
8
|
+
* What columns come back in unless something asks otherwise.
|
|
9
|
+
*
|
|
10
|
+
* Binary: fewer bytes on the wire and no text to parse for most types.
|
|
11
|
+
* A column named by `fetchAsString`, and the types that have no binary
|
|
12
|
+
* decoder, come back as text regardless.
|
|
13
|
+
*/
|
|
6
14
|
export const DEFAULT_COLUMN_FORMAT = DataFormat.binary;
|
|
15
|
+
/** Where a connection is between `connect()` and `close()`. */
|
|
7
16
|
export var ConnectionState;
|
|
8
17
|
(function (ConnectionState) {
|
|
9
18
|
ConnectionState[ConnectionState["CLOSED"] = 0] = "CLOSED";
|
|
@@ -12,6 +21,14 @@ export var ConnectionState;
|
|
|
12
21
|
ConnectionState[ConnectionState["READY"] = 2] = "READY";
|
|
13
22
|
ConnectionState[ConnectionState["CLOSING"] = 10] = "CLOSING";
|
|
14
23
|
})(ConnectionState || (ConnectionState = {}));
|
|
24
|
+
/**
|
|
25
|
+
* Every type this client knows, by name, as `pg_type.oid` gives it - the
|
|
26
|
+
* scalar types and their array counterparts, which are named with a
|
|
27
|
+
* leading underscore the way the catalog names them.
|
|
28
|
+
*
|
|
29
|
+
* These are the numbers `BindParam`, `fetchAsString` and a
|
|
30
|
+
* `DataTypeMap`'s own registrations are written with.
|
|
31
|
+
*/
|
|
15
32
|
export const DataTypeOIDs = {
|
|
16
33
|
bool: 16,
|
|
17
34
|
bytea: 17,
|
|
@@ -188,6 +205,7 @@ export const DataTypeOIDs = {
|
|
|
188
205
|
_datemultirange: 6155,
|
|
189
206
|
_int8multirange: 6157,
|
|
190
207
|
};
|
|
208
|
+
/** The name of each type by its OID, for reporting a column's type back to a caller. */
|
|
191
209
|
export const DataTypeNames = {
|
|
192
210
|
[DataTypeOIDs.bool]: 'bool',
|
|
193
211
|
[DataTypeOIDs.bytea]: 'bytea',
|
package/data-type-map.d.ts
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import type { DataType } from './interfaces/data-type.js';
|
|
2
2
|
import type { OID } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Which `DataType` answers for which OID.
|
|
5
|
+
*
|
|
6
|
+
* `GlobalTypeMap` is the one every connection uses unless it was given
|
|
7
|
+
* its own, and it already holds every type this client knows. A caller
|
|
8
|
+
* registers into it to add a type - a PostGIS geometry, a composite of
|
|
9
|
+
* their own - or copies it and registers into the copy to change one
|
|
10
|
+
* type for one connection without touching anyone else's.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* const typeMap = new DataTypeMap(GlobalTypeMap);
|
|
14
|
+
* typeMap.register(MyGeometryType);
|
|
15
|
+
* const connection = new Connection({ ...config, typeMap });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
3
18
|
export declare class DataTypeMap {
|
|
4
19
|
protected _inferScalars: DataType[];
|
|
5
20
|
protected _inferArrays: DataType[];
|
|
@@ -17,7 +32,22 @@ export declare class DataTypeMap {
|
|
|
17
32
|
* nothing reported.
|
|
18
33
|
*/
|
|
19
34
|
constructor(other?: DataTypeMap);
|
|
35
|
+
/**
|
|
36
|
+
* The type registered for an OID.
|
|
37
|
+
*
|
|
38
|
+
* @param oid The type to look up.
|
|
39
|
+
* @returns Its `DataType`, or `undefined` when nothing is registered -
|
|
40
|
+
* in which case values of that type come back as raw `Buffer`s.
|
|
41
|
+
*/
|
|
20
42
|
get(oid: OID): DataType;
|
|
43
|
+
/**
|
|
44
|
+
* Registers a type, or replaces the one already holding its OID.
|
|
45
|
+
*
|
|
46
|
+
* The array counterpart is its own registration: register both to have
|
|
47
|
+
* both read and written.
|
|
48
|
+
*
|
|
49
|
+
* @param dataTypes The type, or several at once.
|
|
50
|
+
*/
|
|
21
51
|
register(dataTypes: DataType | DataType[]): void;
|
|
22
52
|
/**
|
|
23
53
|
* The two lists determine() actually walks, newest-registered first.
|
|
@@ -35,4 +65,12 @@ export declare class DataTypeMap {
|
|
|
35
65
|
protected _rebuildInferenceLists(): void;
|
|
36
66
|
determine(value: any): OID;
|
|
37
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* The map every connection reads unless it was given one of its own -
|
|
70
|
+
* already holding every type this client knows.
|
|
71
|
+
*
|
|
72
|
+
* Registering here changes what every connection in the process does,
|
|
73
|
+
* which is what makes it the place for a type the whole application
|
|
74
|
+
* shares, and the wrong place for one connection's exception.
|
|
75
|
+
*/
|
|
38
76
|
export declare const GlobalTypeMap: DataTypeMap;
|
package/data-type-map.js
CHANGED
|
@@ -40,6 +40,21 @@ import { ArrayUuidType, UuidType } from './data-types/uuid-type.js';
|
|
|
40
40
|
import { ArrayVarcharType, VarcharType } from './data-types/varchar-type.js';
|
|
41
41
|
import { ArrayCidType, ArrayXid8Type, ArrayXidType, CidType, Xid8Type, XidType, } from './data-types/xid-type.js';
|
|
42
42
|
import { arrayLeaf } from './util/array-leaf.js';
|
|
43
|
+
/**
|
|
44
|
+
* Which `DataType` answers for which OID.
|
|
45
|
+
*
|
|
46
|
+
* `GlobalTypeMap` is the one every connection uses unless it was given
|
|
47
|
+
* its own, and it already holds every type this client knows. A caller
|
|
48
|
+
* registers into it to add a type - a PostGIS geometry, a composite of
|
|
49
|
+
* their own - or copies it and registers into the copy to change one
|
|
50
|
+
* type for one connection without touching anyone else's.
|
|
51
|
+
*
|
|
52
|
+
* ```ts
|
|
53
|
+
* const typeMap = new DataTypeMap(GlobalTypeMap);
|
|
54
|
+
* typeMap.register(MyGeometryType);
|
|
55
|
+
* const connection = new Connection({ ...config, typeMap });
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
43
58
|
export class DataTypeMap {
|
|
44
59
|
_inferScalars = [];
|
|
45
60
|
_inferArrays = [];
|
|
@@ -67,9 +82,24 @@ export class DataTypeMap {
|
|
|
67
82
|
this._inferArrays = other._inferArrays;
|
|
68
83
|
}
|
|
69
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* The type registered for an OID.
|
|
87
|
+
*
|
|
88
|
+
* @param oid The type to look up.
|
|
89
|
+
* @returns Its `DataType`, or `undefined` when nothing is registered -
|
|
90
|
+
* in which case values of that type come back as raw `Buffer`s.
|
|
91
|
+
*/
|
|
70
92
|
get(oid) {
|
|
71
93
|
return this._itemsByOID[oid];
|
|
72
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Registers a type, or replaces the one already holding its OID.
|
|
97
|
+
*
|
|
98
|
+
* The array counterpart is its own registration: register both to have
|
|
99
|
+
* both read and written.
|
|
100
|
+
*
|
|
101
|
+
* @param dataTypes The type, or several at once.
|
|
102
|
+
*/
|
|
73
103
|
register(dataTypes) {
|
|
74
104
|
dataTypes = Array.isArray(dataTypes) ? dataTypes : [dataTypes];
|
|
75
105
|
for (const t of dataTypes) {
|
|
@@ -155,6 +185,14 @@ export class DataTypeMap {
|
|
|
155
185
|
return DataTypeOIDs.unknown;
|
|
156
186
|
}
|
|
157
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* The map every connection reads unless it was given one of its own -
|
|
190
|
+
* already holding every type this client knows.
|
|
191
|
+
*
|
|
192
|
+
* Registering here changes what every connection in the process does,
|
|
193
|
+
* which is what makes it the place for a type the whole application
|
|
194
|
+
* shares, and the wrong place for one connection's exception.
|
|
195
|
+
*/
|
|
158
196
|
export const GlobalTypeMap = new DataTypeMap();
|
|
159
197
|
GlobalTypeMap.register([OidType, ArrayOidType]);
|
|
160
198
|
GlobalTypeMap.register([OidVectorType, ArrayOidVectorType]);
|
package/data-types/bit-type.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { DataType } from '../interfaces/data-type.js';
|
|
2
|
+
/** `bit(n)`, as a string of `0`s and `1`s - its own text form, and the only lossless one for a length the server chose. */
|
|
2
3
|
export declare const BitType: DataType;
|
|
4
|
+
/** The `_bit` array of {@link BitType}. */
|
|
3
5
|
export declare const ArrayBitType: DataType;
|
|
6
|
+
/** `varbit` (bit varying), as a string of `0`s and `1`s. */
|
|
4
7
|
export declare const VarbitType: DataType;
|
|
8
|
+
/** The `_varbit` array of {@link VarbitType}. */
|
|
5
9
|
export declare const ArrayVarbitType: DataType;
|
package/data-types/bit-type.js
CHANGED
|
@@ -75,14 +75,18 @@ function createType(name, oid) {
|
|
|
75
75
|
},
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
+
/** `bit(n)`, as a string of `0`s and `1`s - its own text form, and the only lossless one for a length the server chose. */
|
|
78
79
|
export const BitType = createType('bit', DataTypeOIDs.bit);
|
|
80
|
+
/** The `_bit` array of {@link BitType}. */
|
|
79
81
|
export const ArrayBitType = {
|
|
80
82
|
...BitType,
|
|
81
83
|
name: '_bit',
|
|
82
84
|
oid: DataTypeOIDs._bit,
|
|
83
85
|
elementsOID: DataTypeOIDs.bit,
|
|
84
86
|
};
|
|
87
|
+
/** `varbit` (bit varying), as a string of `0`s and `1`s. */
|
|
85
88
|
export const VarbitType = createType('varbit', DataTypeOIDs.varbit);
|
|
89
|
+
/** The `_varbit` array of {@link VarbitType}. */
|
|
86
90
|
export const ArrayVarbitType = {
|
|
87
91
|
...VarbitType,
|
|
88
92
|
name: '_varbit',
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { DataType } from '../interfaces/data-type.js';
|
|
2
|
+
/** `bool`, as a JavaScript boolean. Its text form is the `t`/`f` the server itself writes. */
|
|
2
3
|
export declare const BoolType: DataType;
|
|
4
|
+
/** The `_bool` array of {@link BoolType}. */
|
|
3
5
|
export declare const ArrayBoolType: DataType;
|
package/data-types/bool-type.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DataTypeOIDs } from '../constants.js';
|
|
2
|
+
/** `bool`, as a JavaScript boolean. Its text form is the `t`/`f` the server itself writes. */
|
|
2
3
|
export const BoolType = {
|
|
3
4
|
name: 'bool',
|
|
4
5
|
oid: DataTypeOIDs.bool,
|
|
@@ -25,6 +26,7 @@ export const BoolType = {
|
|
|
25
26
|
return typeof v === 'boolean';
|
|
26
27
|
},
|
|
27
28
|
};
|
|
29
|
+
/** The `_bool` array of {@link BoolType}. */
|
|
28
30
|
export const ArrayBoolType = {
|
|
29
31
|
...BoolType,
|
|
30
32
|
name: '_bool',
|
package/data-types/box-type.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { DataType } from '../interfaces/data-type.js';
|
|
2
|
+
/** `box`, as a {@link Box}. Its array literal separates elements with a semicolon rather than a comma, which is what `arraySeparator` is for. */
|
|
2
3
|
export declare const BoxType: DataType;
|
|
4
|
+
/** The `_box` array of {@link BoxType}. */
|
|
3
5
|
export declare const ArrayBoxType: DataType;
|
package/data-types/box-type.js
CHANGED
|
@@ -3,6 +3,7 @@ import { Box, TwoPoints } from './classes/geometric.js';
|
|
|
3
3
|
const BOX_PATTERN1 = /^\( *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *\)$/;
|
|
4
4
|
const BOX_PATTERN2 = /^\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\)$/;
|
|
5
5
|
const BOX_PATTERN3 = /^(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *, *(-?\d+\.?\d*)$/;
|
|
6
|
+
/** `box`, as a {@link Box}. Its array literal separates elements with a semicolon rather than a comma, which is what `arraySeparator` is for. */
|
|
6
7
|
export const BoxType = {
|
|
7
8
|
name: 'box',
|
|
8
9
|
oid: DataTypeOIDs.box,
|
|
@@ -37,6 +38,7 @@ export const BoxType = {
|
|
|
37
38
|
return v instanceof Box || TwoPoints.isTwoPointsLike(v);
|
|
38
39
|
},
|
|
39
40
|
};
|
|
41
|
+
/** The `_box` array of {@link BoxType}. */
|
|
40
42
|
export const ArrayBoxType = {
|
|
41
43
|
...BoxType,
|
|
42
44
|
name: '_box',
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { DataType } from '../interfaces/data-type.js';
|
|
2
|
+
/** `bytea`, as a `Buffer`. The binary format is the bytes themselves; the text one is `\\x`-prefixed hex, at two characters a byte. */
|
|
2
3
|
export declare const ByteaType: DataType;
|
|
4
|
+
/** The `_bytea` array of {@link ByteaType}. */
|
|
3
5
|
export declare const ArrayByteaType: DataType;
|
package/data-types/bytea-type.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DataTypeOIDs } from '../constants.js';
|
|
2
2
|
import { parseBytea, parseByteaBuffer } from '../util/parse-bytea.js';
|
|
3
|
+
/** `bytea`, as a `Buffer`. The binary format is the bytes themselves; the text one is `\\x`-prefixed hex, at two characters a byte. */
|
|
3
4
|
export const ByteaType = {
|
|
4
5
|
name: 'bytea',
|
|
5
6
|
oid: DataTypeOIDs.bytea,
|
|
@@ -22,6 +23,7 @@ export const ByteaType = {
|
|
|
22
23
|
return v instanceof Buffer;
|
|
23
24
|
},
|
|
24
25
|
};
|
|
26
|
+
/** The `_bytea` array of {@link ByteaType}. */
|
|
25
27
|
export const ArrayByteaType = {
|
|
26
28
|
...ByteaType,
|
|
27
29
|
name: '_bytea',
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { DataType } from '../interfaces/data-type.js';
|
|
2
|
+
/** `char` - the single-byte internal type, not `char(n)` - as a one-character string. */
|
|
2
3
|
export declare const CharType: DataType;
|
|
4
|
+
/** The `_char` array of {@link CharType}. */
|
|
3
5
|
export declare const ArrayCharType: DataType;
|
package/data-types/char-type.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DataTypeOIDs } from '../constants.js';
|
|
2
|
+
/** `char` - the single-byte internal type, not `char(n)` - as a one-character string. */
|
|
2
3
|
export const CharType = {
|
|
3
4
|
name: 'char',
|
|
4
5
|
oid: DataTypeOIDs.char,
|
|
@@ -37,6 +38,7 @@ export const CharType = {
|
|
|
37
38
|
*/
|
|
38
39
|
inferrable: false,
|
|
39
40
|
};
|
|
41
|
+
/** The `_char` array of {@link CharType}. */
|
|
40
42
|
export const ArrayCharType = {
|
|
41
43
|
...CharType,
|
|
42
44
|
name: '_char',
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { DataType } from '../interfaces/data-type.js';
|
|
2
|
+
/** `circle`, as a {@link Circle} - a centre point and a radius, named as PostgreSQL names them. */
|
|
2
3
|
export declare const CircleType: DataType;
|
|
4
|
+
/** The `_circle` array of {@link CircleType}. */
|
|
3
5
|
export declare const ArrayCircleType: DataType;
|
|
@@ -4,6 +4,7 @@ const CIRCLE_PATTERN1 = /^< *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *(-?\d+\
|
|
|
4
4
|
const CIRCLE_PATTERN2 = /^\( *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *(-?\d+\.?\d*) *\)$/;
|
|
5
5
|
const CIRCLE_PATTERN3 = /^\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *(-?\d+\.?\d*)$/;
|
|
6
6
|
const CIRCLE_PATTERN4 = /^(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *, *(-?\d+\.?\d*)$/;
|
|
7
|
+
/** `circle`, as a {@link Circle} - a centre point and a radius, named as PostgreSQL names them. */
|
|
7
8
|
export const CircleType = {
|
|
8
9
|
name: 'circle',
|
|
9
10
|
oid: DataTypeOIDs.circle,
|
|
@@ -40,6 +41,7 @@ export const CircleType = {
|
|
|
40
41
|
return v instanceof Circle || Circle.isCircleLike(v);
|
|
41
42
|
},
|
|
42
43
|
};
|
|
44
|
+
/** The `_circle` array of {@link CircleType}. */
|
|
43
45
|
export const ArrayCircleType = {
|
|
44
46
|
...CircleType,
|
|
45
47
|
name: '_circle',
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { DataType } from '../interfaces/data-type.js';
|
|
2
|
+
/** `date`, as a `Date` at local midnight - or at UTC midnight with `utcDates`. */
|
|
2
3
|
export declare const DateType: DataType;
|
|
4
|
+
/** The `_date` array of {@link DateType}. */
|
|
3
5
|
export declare const ArrayDateType: DataType;
|
package/data-types/date-type.js
CHANGED
|
@@ -3,6 +3,7 @@ import { formatDate } from '../util/format-datetime.js';
|
|
|
3
3
|
import { utcPartsAsLocal } from '../util/local-date.js';
|
|
4
4
|
import { parseDate } from '../util/parse-datetime.js';
|
|
5
5
|
const timeShift = 946684800000;
|
|
6
|
+
/** `date`, as a `Date` at local midnight - or at UTC midnight with `utcDates`. */
|
|
6
7
|
export const DateType = {
|
|
7
8
|
name: 'date',
|
|
8
9
|
oid: DataTypeOIDs.date,
|
|
@@ -56,6 +57,7 @@ export const DateType = {
|
|
|
56
57
|
v.getMilliseconds() === 0);
|
|
57
58
|
},
|
|
58
59
|
};
|
|
60
|
+
/** The `_date` array of {@link DateType}. */
|
|
59
61
|
export const ArrayDateType = {
|
|
60
62
|
...DateType,
|
|
61
63
|
name: '_date',
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { DataType } from '../interfaces/data-type.js';
|
|
2
|
+
/** `float4` (real), as a number - the shortest decimal that reads back as the same 32-bit float. */
|
|
2
3
|
export declare const Float4Type: DataType;
|
|
4
|
+
/** The `_float4` array of {@link Float4Type}. */
|
|
3
5
|
export declare const ArrayFloat4Type: DataType;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DataTypeOIDs } from '../constants.js';
|
|
2
2
|
import { assertCoercedNumber } from '../util/assert-integer.js';
|
|
3
3
|
import { fastParseFloatBuffer } from '../util/fast-parsefloat.js';
|
|
4
|
+
/** `float4` (real), as a number - the shortest decimal that reads back as the same 32-bit float. */
|
|
4
5
|
export const Float4Type = {
|
|
5
6
|
name: 'float4',
|
|
6
7
|
oid: DataTypeOIDs.float4,
|
|
@@ -20,6 +21,7 @@ export const Float4Type = {
|
|
|
20
21
|
return typeof v === 'number';
|
|
21
22
|
},
|
|
22
23
|
};
|
|
24
|
+
/** The `_float4` array of {@link Float4Type}. */
|
|
23
25
|
export const ArrayFloat4Type = {
|
|
24
26
|
...Float4Type,
|
|
25
27
|
name: '_float4',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DataTypeOIDs } from '../constants.js';
|
|
2
2
|
import { assertCoercedNumber } from '../util/assert-integer.js';
|
|
3
3
|
import { fastParseFloatBuffer } from '../util/fast-parsefloat.js';
|
|
4
|
+
/** `float8` (double precision), as a number. */
|
|
4
5
|
export const Float8Type = {
|
|
5
6
|
name: 'float8',
|
|
6
7
|
oid: DataTypeOIDs.float8,
|
|
@@ -21,6 +22,7 @@ export const Float8Type = {
|
|
|
21
22
|
return typeof v === 'number';
|
|
22
23
|
},
|
|
23
24
|
};
|
|
25
|
+
/** The `_float8` array of {@link Float8Type}. */
|
|
24
26
|
export const ArrayFloat8Type = {
|
|
25
27
|
...Float8Type,
|
|
26
28
|
name: '_float8',
|