@prisma/adapter-pg 6.15.0-dev.18 → 6.15.0-dev.19
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/dist/index.d.mts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +24 -8
- package/dist/index.mjs +24 -8
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -10,9 +10,10 @@ import type { Transaction } from '@prisma/driver-adapter-utils';
|
|
|
10
10
|
|
|
11
11
|
declare class PgQueryable<ClientT extends StdClient | TransactionClient> implements SqlQueryable {
|
|
12
12
|
protected readonly client: ClientT;
|
|
13
|
+
protected readonly pgOptions?: PrismaPgOptions | undefined;
|
|
13
14
|
readonly provider = "postgres";
|
|
14
15
|
readonly adapterName: string;
|
|
15
|
-
constructor(client: ClientT);
|
|
16
|
+
constructor(client: ClientT, pgOptions?: PrismaPgOptions | undefined);
|
|
16
17
|
/**
|
|
17
18
|
* Execute a query given as SQL, interpolating the given parameters.
|
|
18
19
|
*/
|
|
@@ -44,9 +45,9 @@ export declare class PrismaPg implements SqlMigrationAwareDriverAdapterFactory {
|
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
declare class PrismaPgAdapter extends PgQueryable<StdClient> implements SqlDriverAdapter {
|
|
47
|
-
|
|
48
|
+
protected readonly pgOptions?: PrismaPgOptions | undefined;
|
|
48
49
|
private readonly release?;
|
|
49
|
-
constructor(client: StdClient,
|
|
50
|
+
constructor(client: StdClient, pgOptions?: PrismaPgOptions | undefined, release?: (() => Promise<void>) | undefined);
|
|
50
51
|
startTransaction(isolationLevel?: IsolationLevel): Promise<Transaction>;
|
|
51
52
|
executeScript(script: string): Promise<void>;
|
|
52
53
|
getConnectionInfo(): ConnectionInfo;
|
|
@@ -59,10 +60,13 @@ declare type PrismaPgOptions = {
|
|
|
59
60
|
disposeExternalPool?: boolean;
|
|
60
61
|
onPoolError?: (err: Error) => void;
|
|
61
62
|
onConnectionError?: (err: Error) => void;
|
|
63
|
+
userDefinedTypeParser?: UserDefinedTypeParser;
|
|
62
64
|
};
|
|
63
65
|
|
|
64
66
|
declare type StdClient = pg.Pool;
|
|
65
67
|
|
|
66
68
|
declare type TransactionClient = pg.PoolClient;
|
|
67
69
|
|
|
70
|
+
declare type UserDefinedTypeParser = (oid: number, value: unknown, adapter: SqlQueryable) => Promise<unknown>;
|
|
71
|
+
|
|
68
72
|
export { }
|
package/dist/index.d.ts
CHANGED
|
@@ -10,9 +10,10 @@ import type { Transaction } from '@prisma/driver-adapter-utils';
|
|
|
10
10
|
|
|
11
11
|
declare class PgQueryable<ClientT extends StdClient | TransactionClient> implements SqlQueryable {
|
|
12
12
|
protected readonly client: ClientT;
|
|
13
|
+
protected readonly pgOptions?: PrismaPgOptions | undefined;
|
|
13
14
|
readonly provider = "postgres";
|
|
14
15
|
readonly adapterName: string;
|
|
15
|
-
constructor(client: ClientT);
|
|
16
|
+
constructor(client: ClientT, pgOptions?: PrismaPgOptions | undefined);
|
|
16
17
|
/**
|
|
17
18
|
* Execute a query given as SQL, interpolating the given parameters.
|
|
18
19
|
*/
|
|
@@ -44,9 +45,9 @@ export declare class PrismaPg implements SqlMigrationAwareDriverAdapterFactory {
|
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
declare class PrismaPgAdapter extends PgQueryable<StdClient> implements SqlDriverAdapter {
|
|
47
|
-
|
|
48
|
+
protected readonly pgOptions?: PrismaPgOptions | undefined;
|
|
48
49
|
private readonly release?;
|
|
49
|
-
constructor(client: StdClient,
|
|
50
|
+
constructor(client: StdClient, pgOptions?: PrismaPgOptions | undefined, release?: (() => Promise<void>) | undefined);
|
|
50
51
|
startTransaction(isolationLevel?: IsolationLevel): Promise<Transaction>;
|
|
51
52
|
executeScript(script: string): Promise<void>;
|
|
52
53
|
getConnectionInfo(): ConnectionInfo;
|
|
@@ -59,10 +60,13 @@ declare type PrismaPgOptions = {
|
|
|
59
60
|
disposeExternalPool?: boolean;
|
|
60
61
|
onPoolError?: (err: Error) => void;
|
|
61
62
|
onConnectionError?: (err: Error) => void;
|
|
63
|
+
userDefinedTypeParser?: UserDefinedTypeParser;
|
|
62
64
|
};
|
|
63
65
|
|
|
64
66
|
declare type StdClient = pg.Pool;
|
|
65
67
|
|
|
66
68
|
declare type TransactionClient = pg.PoolClient;
|
|
67
69
|
|
|
70
|
+
declare type UserDefinedTypeParser = (oid: number, value: unknown, adapter: SqlQueryable) => Promise<unknown>;
|
|
71
|
+
|
|
68
72
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -41,6 +41,9 @@ var import_pg2 = __toESM(require("pg"));
|
|
|
41
41
|
// package.json
|
|
42
42
|
var name = "@prisma/adapter-pg";
|
|
43
43
|
|
|
44
|
+
// src/constants.ts
|
|
45
|
+
var FIRST_NORMAL_OBJECT_ID = 16384;
|
|
46
|
+
|
|
44
47
|
// src/conversion.ts
|
|
45
48
|
var import_driver_adapter_utils = require("@prisma/driver-adapter-utils");
|
|
46
49
|
var import_pg = __toESM(require("pg"));
|
|
@@ -282,7 +285,7 @@ function fieldToColumnType(fieldTypeId) {
|
|
|
282
285
|
case ArrayColumnType.OID_ARRAY:
|
|
283
286
|
return import_driver_adapter_utils.ColumnTypeEnum.Int64Array;
|
|
284
287
|
default:
|
|
285
|
-
if (fieldTypeId >=
|
|
288
|
+
if (fieldTypeId >= FIRST_NORMAL_OBJECT_ID) {
|
|
286
289
|
return import_driver_adapter_utils.ColumnTypeEnum.Text;
|
|
287
290
|
}
|
|
288
291
|
throw new UnsupportedNativeDataType(fieldTypeId);
|
|
@@ -586,8 +589,9 @@ function isTlsError(error) {
|
|
|
586
589
|
var types2 = import_pg2.default.types;
|
|
587
590
|
var debug = (0, import_driver_adapter_utils2.Debug)("prisma:driver-adapter:pg");
|
|
588
591
|
var PgQueryable = class {
|
|
589
|
-
constructor(client) {
|
|
592
|
+
constructor(client, pgOptions) {
|
|
590
593
|
this.client = client;
|
|
594
|
+
this.pgOptions = pgOptions;
|
|
591
595
|
}
|
|
592
596
|
provider = "postgres";
|
|
593
597
|
adapterName = name;
|
|
@@ -611,6 +615,17 @@ var PgQueryable = class {
|
|
|
611
615
|
}
|
|
612
616
|
throw e;
|
|
613
617
|
}
|
|
618
|
+
const udtParser = this.pgOptions?.userDefinedTypeParser;
|
|
619
|
+
if (udtParser) {
|
|
620
|
+
for (let i = 0; i < fields.length; i++) {
|
|
621
|
+
const field = fields[i];
|
|
622
|
+
if (field.dataTypeID >= FIRST_NORMAL_OBJECT_ID && !Object.hasOwn(customParsers, field.dataTypeID)) {
|
|
623
|
+
for (let j = 0; j < rows.length; j++) {
|
|
624
|
+
rows[j][i] = await udtParser(field.dataTypeID, rows[j][i], this);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
614
629
|
return {
|
|
615
630
|
columnNames,
|
|
616
631
|
columnTypes,
|
|
@@ -675,9 +690,10 @@ var PgQueryable = class {
|
|
|
675
690
|
}
|
|
676
691
|
};
|
|
677
692
|
var PgTransaction = class extends PgQueryable {
|
|
678
|
-
constructor(client, options) {
|
|
679
|
-
super(client);
|
|
693
|
+
constructor(client, options, pgOptions) {
|
|
694
|
+
super(client, pgOptions);
|
|
680
695
|
this.options = options;
|
|
696
|
+
this.pgOptions = pgOptions;
|
|
681
697
|
}
|
|
682
698
|
async commit() {
|
|
683
699
|
debug(`[js::commit]`);
|
|
@@ -689,9 +705,9 @@ var PgTransaction = class extends PgQueryable {
|
|
|
689
705
|
}
|
|
690
706
|
};
|
|
691
707
|
var PrismaPgAdapter = class extends PgQueryable {
|
|
692
|
-
constructor(client,
|
|
708
|
+
constructor(client, pgOptions, release) {
|
|
693
709
|
super(client);
|
|
694
|
-
this.
|
|
710
|
+
this.pgOptions = pgOptions;
|
|
695
711
|
this.release = release;
|
|
696
712
|
}
|
|
697
713
|
async startTransaction(isolationLevel) {
|
|
@@ -703,7 +719,7 @@ var PrismaPgAdapter = class extends PgQueryable {
|
|
|
703
719
|
const conn = await this.client.connect().catch((error) => this.onError(error));
|
|
704
720
|
conn.on("error", (err) => {
|
|
705
721
|
debug(`Error from pool connection: ${err.message} %O`, err);
|
|
706
|
-
this.
|
|
722
|
+
this.pgOptions?.onConnectionError?.(err);
|
|
707
723
|
});
|
|
708
724
|
try {
|
|
709
725
|
const tx = new PgTransaction(conn, options);
|
|
@@ -733,7 +749,7 @@ var PrismaPgAdapter = class extends PgQueryable {
|
|
|
733
749
|
}
|
|
734
750
|
getConnectionInfo() {
|
|
735
751
|
return {
|
|
736
|
-
schemaName: this.
|
|
752
|
+
schemaName: this.pgOptions?.schema,
|
|
737
753
|
supportsRelationJoins: true
|
|
738
754
|
};
|
|
739
755
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -5,6 +5,9 @@ import pg2 from "pg";
|
|
|
5
5
|
// package.json
|
|
6
6
|
var name = "@prisma/adapter-pg";
|
|
7
7
|
|
|
8
|
+
// src/constants.ts
|
|
9
|
+
var FIRST_NORMAL_OBJECT_ID = 16384;
|
|
10
|
+
|
|
8
11
|
// src/conversion.ts
|
|
9
12
|
import { ColumnTypeEnum } from "@prisma/driver-adapter-utils";
|
|
10
13
|
import pg from "pg";
|
|
@@ -246,7 +249,7 @@ function fieldToColumnType(fieldTypeId) {
|
|
|
246
249
|
case ArrayColumnType.OID_ARRAY:
|
|
247
250
|
return ColumnTypeEnum.Int64Array;
|
|
248
251
|
default:
|
|
249
|
-
if (fieldTypeId >=
|
|
252
|
+
if (fieldTypeId >= FIRST_NORMAL_OBJECT_ID) {
|
|
250
253
|
return ColumnTypeEnum.Text;
|
|
251
254
|
}
|
|
252
255
|
throw new UnsupportedNativeDataType(fieldTypeId);
|
|
@@ -550,8 +553,9 @@ function isTlsError(error) {
|
|
|
550
553
|
var types2 = pg2.types;
|
|
551
554
|
var debug = Debug("prisma:driver-adapter:pg");
|
|
552
555
|
var PgQueryable = class {
|
|
553
|
-
constructor(client) {
|
|
556
|
+
constructor(client, pgOptions) {
|
|
554
557
|
this.client = client;
|
|
558
|
+
this.pgOptions = pgOptions;
|
|
555
559
|
}
|
|
556
560
|
provider = "postgres";
|
|
557
561
|
adapterName = name;
|
|
@@ -575,6 +579,17 @@ var PgQueryable = class {
|
|
|
575
579
|
}
|
|
576
580
|
throw e;
|
|
577
581
|
}
|
|
582
|
+
const udtParser = this.pgOptions?.userDefinedTypeParser;
|
|
583
|
+
if (udtParser) {
|
|
584
|
+
for (let i = 0; i < fields.length; i++) {
|
|
585
|
+
const field = fields[i];
|
|
586
|
+
if (field.dataTypeID >= FIRST_NORMAL_OBJECT_ID && !Object.hasOwn(customParsers, field.dataTypeID)) {
|
|
587
|
+
for (let j = 0; j < rows.length; j++) {
|
|
588
|
+
rows[j][i] = await udtParser(field.dataTypeID, rows[j][i], this);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
578
593
|
return {
|
|
579
594
|
columnNames,
|
|
580
595
|
columnTypes,
|
|
@@ -639,9 +654,10 @@ var PgQueryable = class {
|
|
|
639
654
|
}
|
|
640
655
|
};
|
|
641
656
|
var PgTransaction = class extends PgQueryable {
|
|
642
|
-
constructor(client, options) {
|
|
643
|
-
super(client);
|
|
657
|
+
constructor(client, options, pgOptions) {
|
|
658
|
+
super(client, pgOptions);
|
|
644
659
|
this.options = options;
|
|
660
|
+
this.pgOptions = pgOptions;
|
|
645
661
|
}
|
|
646
662
|
async commit() {
|
|
647
663
|
debug(`[js::commit]`);
|
|
@@ -653,9 +669,9 @@ var PgTransaction = class extends PgQueryable {
|
|
|
653
669
|
}
|
|
654
670
|
};
|
|
655
671
|
var PrismaPgAdapter = class extends PgQueryable {
|
|
656
|
-
constructor(client,
|
|
672
|
+
constructor(client, pgOptions, release) {
|
|
657
673
|
super(client);
|
|
658
|
-
this.
|
|
674
|
+
this.pgOptions = pgOptions;
|
|
659
675
|
this.release = release;
|
|
660
676
|
}
|
|
661
677
|
async startTransaction(isolationLevel) {
|
|
@@ -667,7 +683,7 @@ var PrismaPgAdapter = class extends PgQueryable {
|
|
|
667
683
|
const conn = await this.client.connect().catch((error) => this.onError(error));
|
|
668
684
|
conn.on("error", (err) => {
|
|
669
685
|
debug(`Error from pool connection: ${err.message} %O`, err);
|
|
670
|
-
this.
|
|
686
|
+
this.pgOptions?.onConnectionError?.(err);
|
|
671
687
|
});
|
|
672
688
|
try {
|
|
673
689
|
const tx = new PgTransaction(conn, options);
|
|
@@ -697,7 +713,7 @@ var PrismaPgAdapter = class extends PgQueryable {
|
|
|
697
713
|
}
|
|
698
714
|
getConnectionInfo() {
|
|
699
715
|
return {
|
|
700
|
-
schemaName: this.
|
|
716
|
+
schemaName: this.pgOptions?.schema,
|
|
701
717
|
supportsRelationJoins: true
|
|
702
718
|
};
|
|
703
719
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/adapter-pg",
|
|
3
|
-
"version": "6.15.0-dev.
|
|
3
|
+
"version": "6.15.0-dev.19",
|
|
4
4
|
"description": "Prisma's driver adapter for \"pg\"",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"postgres-array": "3.0.4",
|
|
35
35
|
"pg": "^8.11.3",
|
|
36
|
-
"@prisma/driver-adapter-utils": "6.15.0-dev.
|
|
36
|
+
"@prisma/driver-adapter-utils": "6.15.0-dev.19"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@swc/core": "1.11.5",
|