@m2k-5f/pgtx 2.3.0 → 2.3.2
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/README.md +366 -320
- package/dist/connection.d.ts +1 -0
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +5 -3
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/pool.d.ts.map +1 -1
- package/dist/pool.js +6 -4
- package/dist/protocol/connection-request-writer.js +1 -1
- package/dist/protocol/connection-response-reader.d.ts +9 -1
- package/dist/protocol/connection-response-reader.d.ts.map +1 -1
- package/dist/protocol/connection-response-reader.js +146 -6
- package/dist/protocol/constants.d.ts +48 -0
- package/dist/protocol/constants.d.ts.map +1 -1
- package/dist/protocol/constants.js +47 -0
- package/dist/query.d.ts +2 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +21 -0
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +7 -3
package/dist/connection.d.ts
CHANGED
package/dist/connection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAK3C,OAAO,EAAQ,MAAM,EAAU,MAAM,eAAe,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC,KAAK,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;AAErD,MAAM,MAAM,gBAAgB,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE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AY;IAuDpB,OAAO,CAAC,WAAW;IAwBnB,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,MAAM;IAsBd,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,qBAAqB;YAWf,UAAU;IAmBxB,OAAO,CAAC,qBAAqB;IAW7B,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,aAAa;IAoJrB;;;OAGG;IACH,IAAI,QAAQ,YAEX;IAGD;;;;;;;;;OASG;IACH,KAAK;CAQR"}
|
package/dist/connection.js
CHANGED
|
@@ -2,7 +2,6 @@ import { nextTick } from "process";
|
|
|
2
2
|
import { ConnectionRequestWriter } from "./protocol/connection-request-writer";
|
|
3
3
|
import { createAuthorizedSocket } from "./protocol/socket-authorization";
|
|
4
4
|
import { ResponseTypes } from "./protocol/constants";
|
|
5
|
-
import { parseRowValues } from "./utils/value-parser";
|
|
6
5
|
import { compileSqlTemplate } from "./utils/template-compiler";
|
|
7
6
|
import { Transaction } from "./transaction";
|
|
8
7
|
import { SocketConnector } from "./protocol/socket-connector";
|
|
@@ -389,7 +388,10 @@ export class Connection {
|
|
|
389
388
|
case ResponseTypes.DataRow:
|
|
390
389
|
{
|
|
391
390
|
const query = this._getCurrentQuery();
|
|
392
|
-
query.
|
|
391
|
+
if (!query.columns) {
|
|
392
|
+
query.columns = this._described.get(query.statementName);
|
|
393
|
+
}
|
|
394
|
+
query.rows.push(reader.readDataRow(query.columns, this.params.int8toBigint));
|
|
393
395
|
}
|
|
394
396
|
break;
|
|
395
397
|
case ResponseTypes.ComandComplete:
|
|
@@ -409,7 +411,7 @@ export class Connection {
|
|
|
409
411
|
}
|
|
410
412
|
query.state = QueryState.Completed;
|
|
411
413
|
this._pipelinesQueue.get().next();
|
|
412
|
-
query.resolve(
|
|
414
|
+
query.resolve(query.toObjects());
|
|
413
415
|
}
|
|
414
416
|
break;
|
|
415
417
|
case ResponseTypes.ErrorResponse:
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { Pool as PgtxPool } from "./pool";
|
|
|
2
2
|
import { IdentifierClause, InsertClause, ArrayClause, UpdateClause, ExcludeUpdateClause, WhereClause, LiteralClause, FragmentClause } from './clauses';
|
|
3
3
|
import { Connection } from "./connection";
|
|
4
4
|
import { Transaction } from "./transaction";
|
|
5
|
-
import { setTypeParser } from "./utils/value-parser";
|
|
6
5
|
/**
|
|
7
6
|
* Core SQL tagging utility for Pgtx.
|
|
8
7
|
* Provides type-safe helpers for building dynamic queries with recursive support.
|
|
@@ -120,6 +119,5 @@ export declare const sql: {
|
|
|
120
119
|
export { Connection as Connection };
|
|
121
120
|
export { Transaction as Transaction };
|
|
122
121
|
export { PgtxPool as Pool };
|
|
123
|
-
export { setTypeParser as setTypeParser };
|
|
124
122
|
export * from "./clauses";
|
|
125
123
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EACH,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,mBAAmB,EAEnB,WAAW,EACX,aAAa,EACb,cAAc,EACjB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EACH,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,mBAAmB,EAEnB,WAAW,EACX,aAAa,EACb,cAAc,EACjB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C;;;GAGG;AACH,eAAO,MAAM,GAAG;IACZ;;;;;;;;;;;OAWG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;;;;OAQG;;IAGH;;;;;;;;;;;KAWC;;IAGD;;;;;;;;;;OAUG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;;;OAQG;;IAGH;;;;;;;;;;;;;;;;;;;OAmBG;;CAEN,CAAA;AAGD;;;GAGG;AAEH,OAAO,EAAE,UAAU,IAAI,UAAU,EAAE,CAAA;AAEnC,OAAO,EAAE,WAAW,IAAI,WAAW,EAAE,CAAA;AAErC,OAAO,EAAE,QAAQ,IAAI,IAAI,EAAE,CAAA;AAG3B,cAAc,WAAW,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,6 @@ import { Pool as PgtxPool } from "./pool";
|
|
|
2
2
|
import { IdentifierClause, InsertClause, ArrayClause, UpdateClause, ExcludeUpdateClause, emptyClause, WhereClause, LiteralClause, FragmentClause, } from './clauses';
|
|
3
3
|
import { Connection } from "./connection";
|
|
4
4
|
import { Transaction } from "./transaction";
|
|
5
|
-
import { setTypeParser } from "./utils/value-parser";
|
|
6
5
|
/**
|
|
7
6
|
* Core SQL tagging utility for Pgtx.
|
|
8
7
|
* Provides type-safe helpers for building dynamic queries with recursive support.
|
|
@@ -120,5 +119,4 @@ export const sql = {
|
|
|
120
119
|
export { Connection as Connection };
|
|
121
120
|
export { Transaction as Transaction };
|
|
122
121
|
export { PgtxPool as Pool };
|
|
123
|
-
export { setTypeParser as setTypeParser };
|
|
124
122
|
export * from "./clauses";
|
package/dist/pool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAA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AChD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGxC,KAAK,UAAU,GAAG,gBAAgB,GAAG;IACjC,GAAG,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAQD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,qBAAa,IAAI;IACb,OAAO,CAAC,UAAU,CAA0B;IAC5C,OAAO,CAAC,OAAO,CAAkB;IACjC,OAAO,CAAC,IAAI,CAAQ;IACpB,OAAO,CAAC,MAAM,CAAI;IAClB,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,SAAS,CAAQ;IAEzB,OAAO,CAAC,YAAY;gBAIR,MAAM,EAAE,UAAU;IAM9B;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO;IA0BP;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,IAAI,EAAE,UAAU;IAoBxB;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC;IAW7D;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,oBAAoB,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAiCpF;;;;;;;;;;OAUG;IACH,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,GAAE,MAAW,GACuB,MAAM,CAAC,EAAE,EAAE,aAAa,CAAC;IAIhG;;OAEG;IACH,IAAI,IAAI,WAEP;IAGD;;;OAGG;IACH,IAAI,KAAK,WAER;IAGD;;;;;;;;;;OAUG;IACH,KAAK;CAeR"}
|
package/dist/pool.js
CHANGED
|
@@ -169,11 +169,13 @@ export class Pool {
|
|
|
169
169
|
this._checkClosed();
|
|
170
170
|
while (this._available.hasMore) {
|
|
171
171
|
const conn = this._available.get();
|
|
172
|
-
if (conn.isOpened) {
|
|
173
|
-
return conn.query(templates, ...args);
|
|
174
|
-
}
|
|
175
172
|
this._available.next();
|
|
176
|
-
|
|
173
|
+
if (!conn.isOpened) {
|
|
174
|
+
this._total--;
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
this._available.push(conn);
|
|
178
|
+
return conn.query(templates, ...args);
|
|
177
179
|
}
|
|
178
180
|
if (this._total < this._max) {
|
|
179
181
|
this._total++;
|
|
@@ -110,7 +110,7 @@ export class ConnectionRequestWriter {
|
|
|
110
110
|
request.writeInt32(param ? Buffer.byteLength(param) : -1);
|
|
111
111
|
param && request.writeString(param);
|
|
112
112
|
});
|
|
113
|
-
request.writeInt16(
|
|
113
|
+
request.writeInt16(1).writeInt16(1).endRequest();
|
|
114
114
|
return this;
|
|
115
115
|
}
|
|
116
116
|
writeClose(name) {
|
|
@@ -14,8 +14,16 @@ export declare class ConnectionResponseBuffer {
|
|
|
14
14
|
readRawString(length: number): string;
|
|
15
15
|
readBytes(length: number): Buffer;
|
|
16
16
|
hasMore(): boolean;
|
|
17
|
+
readRawBinaryString(length: number): string;
|
|
18
|
+
readBinaryDate(): Date;
|
|
19
|
+
readBinaryTimestamp(): Date;
|
|
20
|
+
readBinaryTime(): string;
|
|
21
|
+
skipBytes(byteCount: number): void;
|
|
17
22
|
hasFullPacket(): boolean;
|
|
18
23
|
getResidualBuffer(): Buffer<ArrayBufferLike>;
|
|
24
|
+
readBool(): boolean;
|
|
25
|
+
readInt64(): bigint;
|
|
26
|
+
readFloat64(): number;
|
|
19
27
|
}
|
|
20
28
|
export declare class ConnectionResponseReader {
|
|
21
29
|
private buffer;
|
|
@@ -38,7 +46,7 @@ export declare class ConnectionResponseReader {
|
|
|
38
46
|
readSaslMechanisms(): string[];
|
|
39
47
|
readSaslMessage(): string;
|
|
40
48
|
readRowDescription(): ColumnDescription[];
|
|
41
|
-
readDataRow(
|
|
49
|
+
readDataRow(descriptions: ColumnDescription[], int8toBigint?: boolean): any[];
|
|
42
50
|
readNotificationResponse(): {
|
|
43
51
|
name: ChannelName;
|
|
44
52
|
payload: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-response-reader.d.ts","sourceRoot":"","sources":["../../src/protocol/connection-response-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"connection-response-reader.d.ts","sourceRoot":"","sources":["../../src/protocol/connection-response-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAA6B,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC5G,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAM3C,qBAAa,wBAAwB;IAI7B,OAAO,CAAC,MAAM;IAHlB,OAAO,CAAC,KAAK,CAAI;IAEjB,OAAO;IAKP,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM;IAK1B,QAAQ,IAAI,MAAM;IAOlB,SAAS,IAAI,MAAM;IAOnB,SAAS,IAAI,MAAM;IAOnB,WAAW,IAAI,MAAM;IAQrB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAOrC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAOjC,OAAO,IAAI,OAAO;IAKlB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAO3C,cAAc,IAAI,IAAI;IAOtB,mBAAmB,IAAI,IAAI;IAO3B,cAAc,IAAI,MAAM;IAaxB,SAAS,CAAC,SAAS,EAAE,MAAM;IAK3B,aAAa,IAAI,OAAO;IAaxB,iBAAiB;IAIjB,QAAQ;IAMR,SAAS,IAAI,MAAM;IAMnB,WAAW,IAAI,MAAM;CAKxB;AAGD,qBAAa,wBAAwB;IAI7B,OAAO,CAAC,MAAM;IAHlB,OAAO,CAAC,mBAAmB,CAAK;IAEhC,OAAO;IAKP,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM;IAK1B,QAAQ,IAC6B,YAAY;IAIjD,kBAAkB,IAGoB,kBAAkB;IAIxD,WAAW;IAKX,mBAAmB;;;;IAUnB,kBAAkB;;;;IAUlB,iBAAiB,IAAI,aAAa;IA8ClC,iBAAiB,IAEoB,iBAAiB;IAItD,kBAAkB,IAAI,MAAM,EAAE;IAa9B,eAAe,IAAI,MAAM;IAOzB,kBAAkB;IAuBlB,WAAW,CAAC,YAAY,EAAE,iBAAiB,EAAE,EAAE,YAAY,GAAE,OAAe,GAAG,GAAG,EAAE;IAwGpF,wBAAwB;;;;IAUxB,mBAAmB,IAAI,MAAM;IAM7B,OAAO;IAKP,aAAa;IAKb,iBAAiB;IAKjB,iBAAiB;IAKjB,gBAAgB;IAKhB,wBAAwB;IAQxB,UAAU;CAGb"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { DataTypeOids } from "./constants";
|
|
1
2
|
import { PostgresError } from "../error";
|
|
3
|
+
const columnValueCache = new Map();
|
|
4
|
+
const POSTGRES_EPOCH_MS = 946684800000;
|
|
2
5
|
export class ConnectionResponseBuffer {
|
|
3
6
|
constructor(buffer) {
|
|
4
7
|
this.buffer = buffer;
|
|
@@ -41,6 +44,33 @@ export class ConnectionResponseBuffer {
|
|
|
41
44
|
hasMore() {
|
|
42
45
|
return this.caret < this.buffer.length;
|
|
43
46
|
}
|
|
47
|
+
readRawBinaryString(length) {
|
|
48
|
+
const text = this.buffer.toString('latin1', this.caret, this.caret + length);
|
|
49
|
+
this.caret += length;
|
|
50
|
+
return text;
|
|
51
|
+
}
|
|
52
|
+
readBinaryDate() {
|
|
53
|
+
const daysSince2000 = this.readInt32();
|
|
54
|
+
const ms = POSTGRES_EPOCH_MS + (daysSince2000 * 86400000);
|
|
55
|
+
return new Date(ms);
|
|
56
|
+
}
|
|
57
|
+
readBinaryTimestamp() {
|
|
58
|
+
const microSecondsSince2000 = this.readInt64();
|
|
59
|
+
const msSince2000 = Number(microSecondsSince2000 / 1000n);
|
|
60
|
+
return new Date(POSTGRES_EPOCH_MS + msSince2000);
|
|
61
|
+
}
|
|
62
|
+
readBinaryTime() {
|
|
63
|
+
const microSecondsSinceMidnight = this.readInt64();
|
|
64
|
+
const totalMs = Number(microSecondsSinceMidnight / 1000n);
|
|
65
|
+
const seconds = Math.floor(totalMs / 1000);
|
|
66
|
+
const ms = totalMs % 1000;
|
|
67
|
+
const minutes = Math.floor(seconds / 60);
|
|
68
|
+
const hours = Math.floor(minutes / 60);
|
|
69
|
+
return `${String(hours).padStart(2, '0')}:${String(minutes % 60).padStart(2, '0')}:${String(seconds % 60).padStart(2, '0')}.${String(ms).padStart(3, '0')}`;
|
|
70
|
+
}
|
|
71
|
+
skipBytes(byteCount) {
|
|
72
|
+
this.caret += byteCount;
|
|
73
|
+
}
|
|
44
74
|
hasFullPacket() {
|
|
45
75
|
const availableBytes = this.buffer.length - this.caret;
|
|
46
76
|
if (availableBytes < 5)
|
|
@@ -53,6 +83,21 @@ export class ConnectionResponseBuffer {
|
|
|
53
83
|
getResidualBuffer() {
|
|
54
84
|
return this.buffer.subarray(this.caret);
|
|
55
85
|
}
|
|
86
|
+
readBool() {
|
|
87
|
+
const value = this.buffer[this.caret] !== 0;
|
|
88
|
+
this.caret++;
|
|
89
|
+
return value;
|
|
90
|
+
}
|
|
91
|
+
readInt64() {
|
|
92
|
+
const value = this.buffer.readBigInt64BE(this.caret);
|
|
93
|
+
this.caret += 8;
|
|
94
|
+
return value;
|
|
95
|
+
}
|
|
96
|
+
readFloat64() {
|
|
97
|
+
const value = this.buffer.readDoubleBE(this.caret);
|
|
98
|
+
this.caret += 8;
|
|
99
|
+
return value;
|
|
100
|
+
}
|
|
56
101
|
}
|
|
57
102
|
export class ConnectionResponseReader {
|
|
58
103
|
constructor(buffer) {
|
|
@@ -153,7 +198,7 @@ export class ConnectionResponseReader {
|
|
|
153
198
|
return this.buffer.readRawString(dataLength);
|
|
154
199
|
}
|
|
155
200
|
readRowDescription() {
|
|
156
|
-
this.buffer.
|
|
201
|
+
this.buffer.skipBytes(4);
|
|
157
202
|
const columnsCount = this.buffer.readInt16();
|
|
158
203
|
const columns = new Array(columnsCount);
|
|
159
204
|
for (let i = 0; i < columnsCount; i++) {
|
|
@@ -169,17 +214,112 @@ export class ConnectionResponseReader {
|
|
|
169
214
|
}
|
|
170
215
|
return columns;
|
|
171
216
|
}
|
|
172
|
-
readDataRow() {
|
|
173
|
-
this.buffer.
|
|
217
|
+
readDataRow(descriptions, int8toBigint = false) {
|
|
218
|
+
this.buffer.skipBytes(4);
|
|
174
219
|
const fieldsCount = this.buffer.readInt16();
|
|
175
220
|
const rowValues = [];
|
|
176
221
|
for (let i = 0; i < fieldsCount; i++) {
|
|
177
|
-
|
|
222
|
+
let fieldLength = this.buffer.readInt32();
|
|
178
223
|
if (fieldLength === -1) {
|
|
179
224
|
rowValues.push(null);
|
|
225
|
+
continue;
|
|
180
226
|
}
|
|
181
|
-
|
|
182
|
-
|
|
227
|
+
const desc = descriptions[i];
|
|
228
|
+
const oid = desc ? desc.typeOID : 0;
|
|
229
|
+
switch (oid) {
|
|
230
|
+
case DataTypeOids.Jsonb:
|
|
231
|
+
{
|
|
232
|
+
this.buffer.skipBytes(1);
|
|
233
|
+
const jsonText = this.buffer.readRawString(fieldLength - 1);
|
|
234
|
+
rowValues.push(JSON.parse(jsonText));
|
|
235
|
+
}
|
|
236
|
+
break;
|
|
237
|
+
case DataTypeOids.Json:
|
|
238
|
+
{
|
|
239
|
+
const jsonText = this.buffer.readRawString(fieldLength);
|
|
240
|
+
rowValues.push(JSON.parse(jsonText));
|
|
241
|
+
}
|
|
242
|
+
break;
|
|
243
|
+
case DataTypeOids.Int4:
|
|
244
|
+
{
|
|
245
|
+
rowValues.push(this.buffer.readInt32());
|
|
246
|
+
}
|
|
247
|
+
break;
|
|
248
|
+
case DataTypeOids.Int2:
|
|
249
|
+
{
|
|
250
|
+
rowValues.push(this.buffer.readInt16());
|
|
251
|
+
}
|
|
252
|
+
break;
|
|
253
|
+
case DataTypeOids.Bool:
|
|
254
|
+
{
|
|
255
|
+
rowValues.push(this.buffer.readBool());
|
|
256
|
+
}
|
|
257
|
+
break;
|
|
258
|
+
case DataTypeOids.Int8:
|
|
259
|
+
{
|
|
260
|
+
const bigint = this.buffer.readInt64();
|
|
261
|
+
rowValues.push(int8toBigint ? bigint : Number(bigint));
|
|
262
|
+
}
|
|
263
|
+
break;
|
|
264
|
+
case DataTypeOids.Float8:
|
|
265
|
+
{
|
|
266
|
+
rowValues.push(this.buffer.readFloat64());
|
|
267
|
+
}
|
|
268
|
+
break;
|
|
269
|
+
case DataTypeOids.Date:
|
|
270
|
+
{
|
|
271
|
+
rowValues.push(this.buffer.readBinaryDate());
|
|
272
|
+
}
|
|
273
|
+
break;
|
|
274
|
+
case DataTypeOids.Timestamp:
|
|
275
|
+
case DataTypeOids.Timestamptz:
|
|
276
|
+
{
|
|
277
|
+
rowValues.push(this.buffer.readBinaryTimestamp());
|
|
278
|
+
}
|
|
279
|
+
break;
|
|
280
|
+
case DataTypeOids.Time:
|
|
281
|
+
{
|
|
282
|
+
rowValues.push(this.buffer.readBinaryTime());
|
|
283
|
+
}
|
|
284
|
+
break;
|
|
285
|
+
case DataTypeOids.Timetz:
|
|
286
|
+
{
|
|
287
|
+
const timeStr = this.buffer.readBinaryTime();
|
|
288
|
+
this.buffer.skipBytes(4);
|
|
289
|
+
rowValues.push(timeStr);
|
|
290
|
+
}
|
|
291
|
+
break;
|
|
292
|
+
case DataTypeOids.Text:
|
|
293
|
+
case DataTypeOids.Varchar:
|
|
294
|
+
case DataTypeOids.Uuid:
|
|
295
|
+
{
|
|
296
|
+
if (fieldLength <= 32) {
|
|
297
|
+
let cacheForColumn = columnValueCache.get(i);
|
|
298
|
+
if (!cacheForColumn) {
|
|
299
|
+
cacheForColumn = new Map();
|
|
300
|
+
columnValueCache.set(i, cacheForColumn);
|
|
301
|
+
}
|
|
302
|
+
const byteKey = this.buffer.readRawBinaryString(fieldLength);
|
|
303
|
+
let cachedString = cacheForColumn.get(byteKey);
|
|
304
|
+
if (cachedString === undefined) {
|
|
305
|
+
cachedString = Buffer.from(byteKey, 'binary').toString('utf-8');
|
|
306
|
+
if (cacheForColumn.size < 512) {
|
|
307
|
+
cacheForColumn.set(byteKey, cachedString);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
rowValues.push(cachedString);
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
rowValues.push(this.buffer.readRawString(fieldLength));
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
break;
|
|
317
|
+
default:
|
|
318
|
+
{
|
|
319
|
+
this.buffer.skipBytes(fieldLength);
|
|
320
|
+
rowValues.push(undefined);
|
|
321
|
+
}
|
|
322
|
+
break;
|
|
183
323
|
}
|
|
184
324
|
}
|
|
185
325
|
return rowValues;
|
|
@@ -28,6 +28,54 @@ export declare const ResponseTypes: {
|
|
|
28
28
|
readonly Notice: "N";
|
|
29
29
|
readonly NotificationResponse: "A";
|
|
30
30
|
};
|
|
31
|
+
export declare const DataTypeOids: {
|
|
32
|
+
readonly Bool: 16;
|
|
33
|
+
readonly Bytea: 17;
|
|
34
|
+
readonly Char: 18;
|
|
35
|
+
readonly Name: 19;
|
|
36
|
+
readonly Text: 25;
|
|
37
|
+
readonly Varchar: 1043;
|
|
38
|
+
readonly Bpchar: 1042;
|
|
39
|
+
readonly Int2: 21;
|
|
40
|
+
readonly Int4: 23;
|
|
41
|
+
readonly Int8: 20;
|
|
42
|
+
readonly Float4: 700;
|
|
43
|
+
readonly Float8: 701;
|
|
44
|
+
readonly Numeric: 1700;
|
|
45
|
+
readonly Timestamp: 1114;
|
|
46
|
+
readonly Timestamptz: 1184;
|
|
47
|
+
readonly Date: 1082;
|
|
48
|
+
readonly Time: 1083;
|
|
49
|
+
readonly Timetz: 1266;
|
|
50
|
+
readonly Interval: 1186;
|
|
51
|
+
readonly Json: 114;
|
|
52
|
+
readonly Jsonb: 3802;
|
|
53
|
+
readonly Uuid: 2950;
|
|
54
|
+
readonly Cidr: 650;
|
|
55
|
+
readonly Inet: 869;
|
|
56
|
+
readonly Macaddr: 829;
|
|
57
|
+
readonly Oid: 26;
|
|
58
|
+
readonly Xid: 28;
|
|
59
|
+
readonly Cid: 29;
|
|
60
|
+
readonly Regproc: 24;
|
|
61
|
+
readonly Point: 600;
|
|
62
|
+
readonly Lseg: 601;
|
|
63
|
+
readonly Path: 602;
|
|
64
|
+
readonly Box: 603;
|
|
65
|
+
readonly Polygon: 604;
|
|
66
|
+
readonly Line: 628;
|
|
67
|
+
readonly BoolArray: 1000;
|
|
68
|
+
readonly Int2Array: 1005;
|
|
69
|
+
readonly Int4Array: 1007;
|
|
70
|
+
readonly Int8Array: 1016;
|
|
71
|
+
readonly TextArray: 1009;
|
|
72
|
+
readonly VarcharArray: 1015;
|
|
73
|
+
readonly JsonArray: 199;
|
|
74
|
+
readonly JsonbArray: 3807;
|
|
75
|
+
readonly UuidArray: 2951;
|
|
76
|
+
readonly NumericArray: 1231;
|
|
77
|
+
};
|
|
78
|
+
export type DataTypeOid = typeof DataTypeOids[keyof typeof DataTypeOids];
|
|
31
79
|
export type ResponseType = ValueOF<typeof ResponseTypes>;
|
|
32
80
|
export declare const AuthenticationCodes: {
|
|
33
81
|
readonly Ok: 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/protocol/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAElC,eAAO,MAAM,YAAY;;;;;;;;;CASf,CAAA;AAEV,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,YAAY,CAAC,CAAA;AAGtD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;CAiBhB,CAAA;AAGV,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,aAAa,CAAC,CAAA;AAGxD,eAAO,MAAM,mBAAmB;;;;;;;CAOtB,CAAA;AAEV,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAGpE,eAAO,MAAM,mBAAmB;;;;CAItB,CAAA;AAEV,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,mBAAmB,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/protocol/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAElC,eAAO,MAAM,YAAY;;;;;;;;;CASf,CAAA;AAEV,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,YAAY,CAAC,CAAA;AAGtD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;CAiBhB,CAAA;AAGV,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwDf,CAAA;AAEV,MAAM,MAAM,WAAW,GAAG,OAAO,YAAY,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAIzE,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,aAAa,CAAC,CAAA;AAGxD,eAAO,MAAM,mBAAmB;;;;;;;CAOtB,CAAA;AAEV,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAGpE,eAAO,MAAM,mBAAmB;;;;CAItB,CAAA;AAEV,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,mBAAmB,CAAC,CAAA"}
|
|
@@ -26,6 +26,53 @@ export const ResponseTypes = {
|
|
|
26
26
|
Notice: "N",
|
|
27
27
|
NotificationResponse: "A"
|
|
28
28
|
};
|
|
29
|
+
export const DataTypeOids = {
|
|
30
|
+
Bool: 16,
|
|
31
|
+
Bytea: 17,
|
|
32
|
+
Char: 18,
|
|
33
|
+
Name: 19,
|
|
34
|
+
Text: 25,
|
|
35
|
+
Varchar: 1043,
|
|
36
|
+
Bpchar: 1042,
|
|
37
|
+
Int2: 21,
|
|
38
|
+
Int4: 23,
|
|
39
|
+
Int8: 20,
|
|
40
|
+
Float4: 700,
|
|
41
|
+
Float8: 701,
|
|
42
|
+
Numeric: 1700,
|
|
43
|
+
Timestamp: 1114,
|
|
44
|
+
Timestamptz: 1184,
|
|
45
|
+
Date: 1082,
|
|
46
|
+
Time: 1083,
|
|
47
|
+
Timetz: 1266,
|
|
48
|
+
Interval: 1186,
|
|
49
|
+
Json: 114,
|
|
50
|
+
Jsonb: 3802,
|
|
51
|
+
Uuid: 2950,
|
|
52
|
+
Cidr: 650,
|
|
53
|
+
Inet: 869,
|
|
54
|
+
Macaddr: 829,
|
|
55
|
+
Oid: 26,
|
|
56
|
+
Xid: 28,
|
|
57
|
+
Cid: 29,
|
|
58
|
+
Regproc: 24,
|
|
59
|
+
Point: 600,
|
|
60
|
+
Lseg: 601,
|
|
61
|
+
Path: 602,
|
|
62
|
+
Box: 603,
|
|
63
|
+
Polygon: 604,
|
|
64
|
+
Line: 628,
|
|
65
|
+
BoolArray: 1000,
|
|
66
|
+
Int2Array: 1005,
|
|
67
|
+
Int4Array: 1007,
|
|
68
|
+
Int8Array: 1016,
|
|
69
|
+
TextArray: 1009,
|
|
70
|
+
VarcharArray: 1015,
|
|
71
|
+
JsonArray: 199,
|
|
72
|
+
JsonbArray: 3807,
|
|
73
|
+
UuidArray: 2951,
|
|
74
|
+
NumericArray: 1231
|
|
75
|
+
};
|
|
29
76
|
export const AuthenticationCodes = {
|
|
30
77
|
Ok: 0,
|
|
31
78
|
CleartextPassword: 3,
|
package/dist/query.d.ts
CHANGED
|
@@ -17,8 +17,9 @@ export declare class Query<T> {
|
|
|
17
17
|
promise: Promise<T[]>;
|
|
18
18
|
resolve: (value: T[]) => void;
|
|
19
19
|
reject: (error: Error) => void;
|
|
20
|
-
rows:
|
|
20
|
+
rows: any[][];
|
|
21
21
|
constructor(text: QueryText, args: (string | null)[], state: State, statementName: StatementName, columns?: ColumnDescription[] | undefined);
|
|
22
22
|
setState(state: State): void;
|
|
23
|
+
toObjects(): T[];
|
|
23
24
|
}
|
|
24
25
|
//# sourceMappingURL=query.d.ts.map
|
package/dist/query.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGrD,eAAO,MAAM,UAAU;;;;;;CAMb,CAAA;AAGV,MAAM,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,UAAU,CAAC,CAAA;AAG9C,qBAAa,KAAK,CAAC,CAAC;IAOL,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE;IACvB,KAAK,EAAE,KAAK;IACZ,aAAa,EAAE,aAAa;IAC5B,OAAO,CAAC,EAAE,iBAAiB,EAAE;IAVxC,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAA;IACrB,OAAO,EAAG,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,IAAI,CAAA;IAC9B,MAAM,EAAG,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IAC/B,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGrD,eAAO,MAAM,UAAU;;;;;;CAMb,CAAA;AAGV,MAAM,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,UAAU,CAAC,CAAA;AAG9C,qBAAa,KAAK,CAAC,CAAC;IAOL,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE;IACvB,KAAK,EAAE,KAAK;IACZ,aAAa,EAAE,aAAa;IAC5B,OAAO,CAAC,EAAE,iBAAiB,EAAE;IAVxC,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAA;IACrB,OAAO,EAAG,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,IAAI,CAAA;IAC9B,MAAM,EAAG,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IAC/B,IAAI,EAAE,GAAG,EAAE,EAAE,CAAK;gBAGP,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,EACvB,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,aAAa,EAC5B,OAAO,CAAC,EAAE,iBAAiB,EAAE,YAAA;IAQxC,QAAQ,CAAC,KAAK,EAAE,KAAK;IAIrB,SAAS,IAAI,CAAC,EAAE;CA2BnB"}
|
package/dist/query.js
CHANGED
|
@@ -21,4 +21,25 @@ export class Query {
|
|
|
21
21
|
setState(state) {
|
|
22
22
|
this.state = state;
|
|
23
23
|
}
|
|
24
|
+
toObjects() {
|
|
25
|
+
if (!this.rows.length || !this.columns || !this.columns.length) {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
const result = [];
|
|
29
|
+
const rowsLength = this.rows.length;
|
|
30
|
+
const columnsLength = this.columns.length;
|
|
31
|
+
const colNames = new Array(columnsLength);
|
|
32
|
+
for (let c = 0; c < columnsLength; c++) {
|
|
33
|
+
colNames[c] = this.columns[c].name;
|
|
34
|
+
}
|
|
35
|
+
for (let r = 0; r < rowsLength; r++) {
|
|
36
|
+
const rawRow = this.rows[r];
|
|
37
|
+
const rowObject = {};
|
|
38
|
+
for (let c = 0; c < columnsLength; c++) {
|
|
39
|
+
rowObject[colNames[c]] = rawRow[c];
|
|
40
|
+
}
|
|
41
|
+
result.push(rowObject);
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
24
45
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DataTypeOid } from "./protocol/constants";
|
|
1
2
|
export type PreparedStatement<TResult extends any, Tparams extends any[]> = {
|
|
2
3
|
text: string;
|
|
3
4
|
name: string;
|
|
@@ -17,7 +18,7 @@ export type CompileSQLParams = {
|
|
|
17
18
|
};
|
|
18
19
|
export type ColumnDescription = {
|
|
19
20
|
name: string;
|
|
20
|
-
typeOID:
|
|
21
|
+
typeOID: DataTypeOid;
|
|
21
22
|
};
|
|
22
23
|
export type Branded<T, Brand> = T & {
|
|
23
24
|
__brand: Brand;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,CAAC,OAAO,SAAS,GAAG,EAAE,OAAO,SAAS,GAAG,EAAE,IAAI;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;CACpD,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;CAC3B,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IAC/B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,IAAI,EAAE,GAAG,EAAE,CAAC;CACf,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC3B,SAAS,EAAE,oBAAoB,CAAC;IAChC,IAAI,EAAE,GAAG,EAAE,CAAC;CACf,CAAA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/pgtx",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.2",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "Blazing-fast PostgreSQL driver with pipeline support.",
|
|
5
6
|
"files": [
|
|
6
7
|
"dist",
|
|
@@ -9,8 +10,9 @@
|
|
|
9
10
|
"scripts": {
|
|
10
11
|
"build": "tsc",
|
|
11
12
|
"prepublishOnly": "npm run build",
|
|
12
|
-
"testGitHub": "node --import tsx --test
|
|
13
|
-
"test": "node --import tsx --test ./tests/*.test.ts"
|
|
13
|
+
"testGitHub": "node --import tsx --test $(find tests -name '*.test.ts')",
|
|
14
|
+
"test": "node --import tsx --test ./tests/*.test.ts",
|
|
15
|
+
"benchmark": "npx tsx benchmark.ts"
|
|
14
16
|
},
|
|
15
17
|
"repository": {
|
|
16
18
|
"type": "git",
|
|
@@ -41,7 +43,9 @@
|
|
|
41
43
|
},
|
|
42
44
|
"devDependencies": {
|
|
43
45
|
"@types/node": "^26.1.1",
|
|
46
|
+
"mitata": "^1.0.34",
|
|
44
47
|
"pg": "^8.22.0",
|
|
48
|
+
"postgres": "^3.4.9",
|
|
45
49
|
"tsx": "^4.21.0",
|
|
46
50
|
"typescript": "^5.0.0"
|
|
47
51
|
},
|