@prisma/adapter-pg 6.5.0-dev.7 → 6.5.0-dev.70
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 +15 -12
- package/dist/index.d.ts +15 -12
- package/dist/index.js +49 -36
- package/dist/index.mjs +52 -37
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { ConnectionInfo } from '@prisma/driver-adapter-utils';
|
|
2
|
-
import type { DriverAdapter } from '@prisma/driver-adapter-utils';
|
|
3
2
|
import pg from 'pg';
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
3
|
+
import type { SqlConnection } from '@prisma/driver-adapter-utils';
|
|
4
|
+
import type { SqlQuery } from '@prisma/driver-adapter-utils';
|
|
5
|
+
import type { SqlQueryable } from '@prisma/driver-adapter-utils';
|
|
6
|
+
import type { SqlResultSet } from '@prisma/driver-adapter-utils';
|
|
8
7
|
import type { TransactionContext } from '@prisma/driver-adapter-utils';
|
|
9
8
|
|
|
10
|
-
declare class PgQueryable<ClientT extends StdClient | TransactionClient> implements
|
|
9
|
+
declare class PgQueryable<ClientT extends StdClient | TransactionClient> implements SqlQueryable {
|
|
11
10
|
protected readonly client: ClientT;
|
|
12
11
|
readonly provider = "postgres";
|
|
13
12
|
readonly adapterName: string;
|
|
@@ -15,26 +14,30 @@ declare class PgQueryable<ClientT extends StdClient | TransactionClient> impleme
|
|
|
15
14
|
/**
|
|
16
15
|
* Execute a query given as SQL, interpolating the given parameters.
|
|
17
16
|
*/
|
|
18
|
-
queryRaw(query:
|
|
17
|
+
queryRaw(query: SqlQuery): Promise<SqlResultSet>;
|
|
19
18
|
/**
|
|
20
19
|
* Execute a query given as SQL, interpolating the given parameters and
|
|
21
20
|
* returning the number of affected rows.
|
|
22
21
|
* Note: Queryable expects a u64, but napi.rs only supports u32.
|
|
23
22
|
*/
|
|
24
|
-
executeRaw(query:
|
|
23
|
+
executeRaw(query: SqlQuery): Promise<number>;
|
|
25
24
|
/**
|
|
26
25
|
* Run a query against the database, returning the result set.
|
|
27
26
|
* Should the query fail due to a connection error, the connection is
|
|
28
27
|
* marked as unhealthy.
|
|
29
28
|
*/
|
|
30
29
|
private performIO;
|
|
30
|
+
protected onError(error: any): never;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export declare class PrismaPg extends PgQueryable<StdClient> implements
|
|
33
|
+
export declare class PrismaPg extends PgQueryable<StdClient> implements SqlConnection {
|
|
34
34
|
private options?;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
private readonly release?;
|
|
36
|
+
constructor(client: StdClient, options?: PrismaPgOptions | undefined, release?: (() => Promise<void>) | undefined);
|
|
37
|
+
executeScript(script: string): Promise<void>;
|
|
38
|
+
getConnectionInfo(): ConnectionInfo;
|
|
39
|
+
transactionContext(): Promise<TransactionContext>;
|
|
40
|
+
dispose(): Promise<void>;
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
declare type PrismaPgOptions = {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { ConnectionInfo } from '@prisma/driver-adapter-utils';
|
|
2
|
-
import type { DriverAdapter } from '@prisma/driver-adapter-utils';
|
|
3
2
|
import pg from 'pg';
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
3
|
+
import type { SqlConnection } from '@prisma/driver-adapter-utils';
|
|
4
|
+
import type { SqlQuery } from '@prisma/driver-adapter-utils';
|
|
5
|
+
import type { SqlQueryable } from '@prisma/driver-adapter-utils';
|
|
6
|
+
import type { SqlResultSet } from '@prisma/driver-adapter-utils';
|
|
8
7
|
import type { TransactionContext } from '@prisma/driver-adapter-utils';
|
|
9
8
|
|
|
10
|
-
declare class PgQueryable<ClientT extends StdClient | TransactionClient> implements
|
|
9
|
+
declare class PgQueryable<ClientT extends StdClient | TransactionClient> implements SqlQueryable {
|
|
11
10
|
protected readonly client: ClientT;
|
|
12
11
|
readonly provider = "postgres";
|
|
13
12
|
readonly adapterName: string;
|
|
@@ -15,26 +14,30 @@ declare class PgQueryable<ClientT extends StdClient | TransactionClient> impleme
|
|
|
15
14
|
/**
|
|
16
15
|
* Execute a query given as SQL, interpolating the given parameters.
|
|
17
16
|
*/
|
|
18
|
-
queryRaw(query:
|
|
17
|
+
queryRaw(query: SqlQuery): Promise<SqlResultSet>;
|
|
19
18
|
/**
|
|
20
19
|
* Execute a query given as SQL, interpolating the given parameters and
|
|
21
20
|
* returning the number of affected rows.
|
|
22
21
|
* Note: Queryable expects a u64, but napi.rs only supports u32.
|
|
23
22
|
*/
|
|
24
|
-
executeRaw(query:
|
|
23
|
+
executeRaw(query: SqlQuery): Promise<number>;
|
|
25
24
|
/**
|
|
26
25
|
* Run a query against the database, returning the result set.
|
|
27
26
|
* Should the query fail due to a connection error, the connection is
|
|
28
27
|
* marked as unhealthy.
|
|
29
28
|
*/
|
|
30
29
|
private performIO;
|
|
30
|
+
protected onError(error: any): never;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export declare class PrismaPg extends PgQueryable<StdClient> implements
|
|
33
|
+
export declare class PrismaPg extends PgQueryable<StdClient> implements SqlConnection {
|
|
34
34
|
private options?;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
private readonly release?;
|
|
36
|
+
constructor(client: StdClient, options?: PrismaPgOptions | undefined, release?: (() => Promise<void>) | undefined);
|
|
37
|
+
executeScript(script: string): Promise<void>;
|
|
38
|
+
getConnectionInfo(): ConnectionInfo;
|
|
39
|
+
transactionContext(): Promise<TransactionContext>;
|
|
40
|
+
dispose(): Promise<void>;
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
declare type PrismaPgOptions = {
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
9
|
var __export = (target, all) => {
|
|
9
10
|
for (var name2 in all)
|
|
10
11
|
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
@@ -26,6 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
27
|
mod
|
|
27
28
|
));
|
|
28
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
29
31
|
|
|
30
32
|
// src/index.ts
|
|
31
33
|
var index_exports = {};
|
|
@@ -77,12 +79,13 @@ var ArrayColumnType = {
|
|
|
77
79
|
var _UnsupportedNativeDataType = class _UnsupportedNativeDataType extends Error {
|
|
78
80
|
constructor(code) {
|
|
79
81
|
super();
|
|
82
|
+
__publicField(this, "type");
|
|
80
83
|
this.type = _UnsupportedNativeDataType.typeNames[code] || "Unknown";
|
|
81
84
|
this.message = `Unsupported column type ${this.type}`;
|
|
82
85
|
}
|
|
83
86
|
};
|
|
84
87
|
// map of type codes to type names
|
|
85
|
-
_UnsupportedNativeDataType
|
|
88
|
+
__publicField(_UnsupportedNativeDataType, "typeNames", {
|
|
86
89
|
16: "bool",
|
|
87
90
|
17: "bytea",
|
|
88
91
|
18: "char",
|
|
@@ -195,7 +198,7 @@ _UnsupportedNativeDataType.typeNames = {
|
|
|
195
198
|
5078: "anycompatiblearray",
|
|
196
199
|
5079: "anycompatiblenonarray",
|
|
197
200
|
5080: "anycompatiblerange"
|
|
198
|
-
};
|
|
201
|
+
});
|
|
199
202
|
var UnsupportedNativeDataType = _UnsupportedNativeDataType;
|
|
200
203
|
function fieldToColumnType(fieldTypeId) {
|
|
201
204
|
switch (fieldTypeId) {
|
|
@@ -374,8 +377,8 @@ var debug = (0, import_driver_adapter_utils2.Debug)("prisma:driver-adapter:pg");
|
|
|
374
377
|
var PgQueryable = class {
|
|
375
378
|
constructor(client) {
|
|
376
379
|
this.client = client;
|
|
377
|
-
this
|
|
378
|
-
this
|
|
380
|
+
__publicField(this, "provider", "postgres");
|
|
381
|
+
__publicField(this, "adapterName", name);
|
|
379
382
|
}
|
|
380
383
|
/**
|
|
381
384
|
* Execute a query given as SQL, interpolating the given parameters.
|
|
@@ -383,29 +386,25 @@ var PgQueryable = class {
|
|
|
383
386
|
async queryRaw(query) {
|
|
384
387
|
const tag = "[js::query_raw]";
|
|
385
388
|
debug(`${tag} %O`, query);
|
|
386
|
-
const
|
|
387
|
-
if (!res.ok) {
|
|
388
|
-
return (0, import_driver_adapter_utils2.err)(res.error);
|
|
389
|
-
}
|
|
390
|
-
const { fields, rows } = res.value;
|
|
389
|
+
const { fields, rows } = await this.performIO(query);
|
|
391
390
|
const columnNames = fields.map((field) => field.name);
|
|
392
391
|
let columnTypes = [];
|
|
393
392
|
try {
|
|
394
393
|
columnTypes = fields.map((field) => fieldToColumnType(field.dataTypeID));
|
|
395
394
|
} catch (e) {
|
|
396
395
|
if (e instanceof UnsupportedNativeDataType) {
|
|
397
|
-
|
|
396
|
+
throw new import_driver_adapter_utils2.DriverAdapterError({
|
|
398
397
|
kind: "UnsupportedNativeDataType",
|
|
399
398
|
type: e.type
|
|
400
399
|
});
|
|
401
400
|
}
|
|
402
401
|
throw e;
|
|
403
402
|
}
|
|
404
|
-
return
|
|
403
|
+
return {
|
|
405
404
|
columnNames,
|
|
406
405
|
columnTypes,
|
|
407
406
|
rows
|
|
408
|
-
}
|
|
407
|
+
};
|
|
409
408
|
}
|
|
410
409
|
/**
|
|
411
410
|
* Execute a query given as SQL, interpolating the given parameters and
|
|
@@ -415,7 +414,7 @@ var PgQueryable = class {
|
|
|
415
414
|
async executeRaw(query) {
|
|
416
415
|
const tag = "[js::execute_raw]";
|
|
417
416
|
debug(`${tag} %O`, query);
|
|
418
|
-
return (await this.performIO(query)).
|
|
417
|
+
return (await this.performIO(query)).rowCount ?? 0;
|
|
419
418
|
}
|
|
420
419
|
/**
|
|
421
420
|
* Run a query against the database, returning the result set.
|
|
@@ -453,23 +452,25 @@ var PgQueryable = class {
|
|
|
453
452
|
},
|
|
454
453
|
fixArrayBufferValues(values)
|
|
455
454
|
);
|
|
456
|
-
return
|
|
455
|
+
return result;
|
|
457
456
|
} catch (e) {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
457
|
+
this.onError(e);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
onError(error) {
|
|
461
|
+
debug("Error in performIO: %O", error);
|
|
462
|
+
if (error && typeof error.code === "string" && typeof error.severity === "string" && typeof error.message === "string") {
|
|
463
|
+
throw new import_driver_adapter_utils2.DriverAdapterError({
|
|
464
|
+
kind: "postgres",
|
|
465
|
+
code: error.code,
|
|
466
|
+
severity: error.severity,
|
|
467
|
+
message: error.message,
|
|
468
|
+
detail: error.detail,
|
|
469
|
+
column: error.column,
|
|
470
|
+
hint: error.hint
|
|
471
|
+
});
|
|
472
472
|
}
|
|
473
|
+
throw error;
|
|
473
474
|
}
|
|
474
475
|
};
|
|
475
476
|
var PgTransaction = class extends PgQueryable {
|
|
@@ -480,12 +481,10 @@ var PgTransaction = class extends PgQueryable {
|
|
|
480
481
|
async commit() {
|
|
481
482
|
debug(`[js::commit]`);
|
|
482
483
|
this.client.release();
|
|
483
|
-
return (0, import_driver_adapter_utils2.ok)(void 0);
|
|
484
484
|
}
|
|
485
485
|
async rollback() {
|
|
486
486
|
debug(`[js::rollback]`);
|
|
487
487
|
this.client.release();
|
|
488
|
-
return (0, import_driver_adapter_utils2.ok)(void 0);
|
|
489
488
|
}
|
|
490
489
|
};
|
|
491
490
|
var PgTransactionContext = class extends PgQueryable {
|
|
@@ -499,12 +498,12 @@ var PgTransactionContext = class extends PgQueryable {
|
|
|
499
498
|
};
|
|
500
499
|
const tag = "[js::startTransaction]";
|
|
501
500
|
debug("%s options: %O", tag, options);
|
|
502
|
-
return
|
|
501
|
+
return new PgTransaction(this.conn, options);
|
|
503
502
|
}
|
|
504
503
|
};
|
|
505
504
|
var PrismaPg = class extends PgQueryable {
|
|
506
|
-
constructor(client, options) {
|
|
507
|
-
if (!
|
|
505
|
+
constructor(client, options, release) {
|
|
506
|
+
if (!client) {
|
|
508
507
|
throw new TypeError(`PrismaPg must be initialized with an instance of Pool:
|
|
509
508
|
import { Pool } from 'pg'
|
|
510
509
|
const pool = new Pool({ connectionString: url })
|
|
@@ -513,15 +512,29 @@ const adapter = new PrismaPg(pool)
|
|
|
513
512
|
}
|
|
514
513
|
super(client);
|
|
515
514
|
this.options = options;
|
|
515
|
+
this.release = release;
|
|
516
|
+
}
|
|
517
|
+
async executeScript(script) {
|
|
518
|
+
for (const stmt of script.split(";")) {
|
|
519
|
+
try {
|
|
520
|
+
await this.client.query(stmt);
|
|
521
|
+
} catch (error) {
|
|
522
|
+
this.onError(error);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
516
525
|
}
|
|
517
526
|
getConnectionInfo() {
|
|
518
|
-
return
|
|
527
|
+
return {
|
|
519
528
|
schemaName: this.options?.schema
|
|
520
|
-
}
|
|
529
|
+
};
|
|
521
530
|
}
|
|
522
531
|
async transactionContext() {
|
|
523
532
|
const conn = await this.client.connect();
|
|
524
|
-
return
|
|
533
|
+
return new PgTransactionContext(conn);
|
|
534
|
+
}
|
|
535
|
+
async dispose() {
|
|
536
|
+
await this.release?.();
|
|
537
|
+
return await this.client.end();
|
|
525
538
|
}
|
|
526
539
|
};
|
|
527
540
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
|
|
1
5
|
// src/pg.ts
|
|
2
|
-
import { Debug,
|
|
6
|
+
import { Debug, DriverAdapterError } from "@prisma/driver-adapter-utils";
|
|
3
7
|
import pg2 from "pg";
|
|
4
8
|
|
|
5
9
|
// package.json
|
|
@@ -41,12 +45,13 @@ var ArrayColumnType = {
|
|
|
41
45
|
var _UnsupportedNativeDataType = class _UnsupportedNativeDataType extends Error {
|
|
42
46
|
constructor(code) {
|
|
43
47
|
super();
|
|
48
|
+
__publicField(this, "type");
|
|
44
49
|
this.type = _UnsupportedNativeDataType.typeNames[code] || "Unknown";
|
|
45
50
|
this.message = `Unsupported column type ${this.type}`;
|
|
46
51
|
}
|
|
47
52
|
};
|
|
48
53
|
// map of type codes to type names
|
|
49
|
-
_UnsupportedNativeDataType
|
|
54
|
+
__publicField(_UnsupportedNativeDataType, "typeNames", {
|
|
50
55
|
16: "bool",
|
|
51
56
|
17: "bytea",
|
|
52
57
|
18: "char",
|
|
@@ -159,7 +164,7 @@ _UnsupportedNativeDataType.typeNames = {
|
|
|
159
164
|
5078: "anycompatiblearray",
|
|
160
165
|
5079: "anycompatiblenonarray",
|
|
161
166
|
5080: "anycompatiblerange"
|
|
162
|
-
};
|
|
167
|
+
});
|
|
163
168
|
var UnsupportedNativeDataType = _UnsupportedNativeDataType;
|
|
164
169
|
function fieldToColumnType(fieldTypeId) {
|
|
165
170
|
switch (fieldTypeId) {
|
|
@@ -338,8 +343,8 @@ var debug = Debug("prisma:driver-adapter:pg");
|
|
|
338
343
|
var PgQueryable = class {
|
|
339
344
|
constructor(client) {
|
|
340
345
|
this.client = client;
|
|
341
|
-
this
|
|
342
|
-
this
|
|
346
|
+
__publicField(this, "provider", "postgres");
|
|
347
|
+
__publicField(this, "adapterName", name);
|
|
343
348
|
}
|
|
344
349
|
/**
|
|
345
350
|
* Execute a query given as SQL, interpolating the given parameters.
|
|
@@ -347,29 +352,25 @@ var PgQueryable = class {
|
|
|
347
352
|
async queryRaw(query) {
|
|
348
353
|
const tag = "[js::query_raw]";
|
|
349
354
|
debug(`${tag} %O`, query);
|
|
350
|
-
const
|
|
351
|
-
if (!res.ok) {
|
|
352
|
-
return err(res.error);
|
|
353
|
-
}
|
|
354
|
-
const { fields, rows } = res.value;
|
|
355
|
+
const { fields, rows } = await this.performIO(query);
|
|
355
356
|
const columnNames = fields.map((field) => field.name);
|
|
356
357
|
let columnTypes = [];
|
|
357
358
|
try {
|
|
358
359
|
columnTypes = fields.map((field) => fieldToColumnType(field.dataTypeID));
|
|
359
360
|
} catch (e) {
|
|
360
361
|
if (e instanceof UnsupportedNativeDataType) {
|
|
361
|
-
|
|
362
|
+
throw new DriverAdapterError({
|
|
362
363
|
kind: "UnsupportedNativeDataType",
|
|
363
364
|
type: e.type
|
|
364
365
|
});
|
|
365
366
|
}
|
|
366
367
|
throw e;
|
|
367
368
|
}
|
|
368
|
-
return
|
|
369
|
+
return {
|
|
369
370
|
columnNames,
|
|
370
371
|
columnTypes,
|
|
371
372
|
rows
|
|
372
|
-
}
|
|
373
|
+
};
|
|
373
374
|
}
|
|
374
375
|
/**
|
|
375
376
|
* Execute a query given as SQL, interpolating the given parameters and
|
|
@@ -379,7 +380,7 @@ var PgQueryable = class {
|
|
|
379
380
|
async executeRaw(query) {
|
|
380
381
|
const tag = "[js::execute_raw]";
|
|
381
382
|
debug(`${tag} %O`, query);
|
|
382
|
-
return (await this.performIO(query)).
|
|
383
|
+
return (await this.performIO(query)).rowCount ?? 0;
|
|
383
384
|
}
|
|
384
385
|
/**
|
|
385
386
|
* Run a query against the database, returning the result set.
|
|
@@ -417,23 +418,25 @@ var PgQueryable = class {
|
|
|
417
418
|
},
|
|
418
419
|
fixArrayBufferValues(values)
|
|
419
420
|
);
|
|
420
|
-
return
|
|
421
|
+
return result;
|
|
421
422
|
} catch (e) {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
423
|
+
this.onError(e);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
onError(error) {
|
|
427
|
+
debug("Error in performIO: %O", error);
|
|
428
|
+
if (error && typeof error.code === "string" && typeof error.severity === "string" && typeof error.message === "string") {
|
|
429
|
+
throw new DriverAdapterError({
|
|
430
|
+
kind: "postgres",
|
|
431
|
+
code: error.code,
|
|
432
|
+
severity: error.severity,
|
|
433
|
+
message: error.message,
|
|
434
|
+
detail: error.detail,
|
|
435
|
+
column: error.column,
|
|
436
|
+
hint: error.hint
|
|
437
|
+
});
|
|
436
438
|
}
|
|
439
|
+
throw error;
|
|
437
440
|
}
|
|
438
441
|
};
|
|
439
442
|
var PgTransaction = class extends PgQueryable {
|
|
@@ -444,12 +447,10 @@ var PgTransaction = class extends PgQueryable {
|
|
|
444
447
|
async commit() {
|
|
445
448
|
debug(`[js::commit]`);
|
|
446
449
|
this.client.release();
|
|
447
|
-
return ok(void 0);
|
|
448
450
|
}
|
|
449
451
|
async rollback() {
|
|
450
452
|
debug(`[js::rollback]`);
|
|
451
453
|
this.client.release();
|
|
452
|
-
return ok(void 0);
|
|
453
454
|
}
|
|
454
455
|
};
|
|
455
456
|
var PgTransactionContext = class extends PgQueryable {
|
|
@@ -463,12 +464,12 @@ var PgTransactionContext = class extends PgQueryable {
|
|
|
463
464
|
};
|
|
464
465
|
const tag = "[js::startTransaction]";
|
|
465
466
|
debug("%s options: %O", tag, options);
|
|
466
|
-
return
|
|
467
|
+
return new PgTransaction(this.conn, options);
|
|
467
468
|
}
|
|
468
469
|
};
|
|
469
470
|
var PrismaPg = class extends PgQueryable {
|
|
470
|
-
constructor(client, options) {
|
|
471
|
-
if (!
|
|
471
|
+
constructor(client, options, release) {
|
|
472
|
+
if (!client) {
|
|
472
473
|
throw new TypeError(`PrismaPg must be initialized with an instance of Pool:
|
|
473
474
|
import { Pool } from 'pg'
|
|
474
475
|
const pool = new Pool({ connectionString: url })
|
|
@@ -477,15 +478,29 @@ const adapter = new PrismaPg(pool)
|
|
|
477
478
|
}
|
|
478
479
|
super(client);
|
|
479
480
|
this.options = options;
|
|
481
|
+
this.release = release;
|
|
482
|
+
}
|
|
483
|
+
async executeScript(script) {
|
|
484
|
+
for (const stmt of script.split(";")) {
|
|
485
|
+
try {
|
|
486
|
+
await this.client.query(stmt);
|
|
487
|
+
} catch (error) {
|
|
488
|
+
this.onError(error);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
480
491
|
}
|
|
481
492
|
getConnectionInfo() {
|
|
482
|
-
return
|
|
493
|
+
return {
|
|
483
494
|
schemaName: this.options?.schema
|
|
484
|
-
}
|
|
495
|
+
};
|
|
485
496
|
}
|
|
486
497
|
async transactionContext() {
|
|
487
498
|
const conn = await this.client.connect();
|
|
488
|
-
return
|
|
499
|
+
return new PgTransactionContext(conn);
|
|
500
|
+
}
|
|
501
|
+
async dispose() {
|
|
502
|
+
await this.release?.();
|
|
503
|
+
return await this.client.end();
|
|
489
504
|
}
|
|
490
505
|
};
|
|
491
506
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/adapter-pg",
|
|
3
|
-
"version": "6.5.0-dev.
|
|
3
|
+
"version": "6.5.0-dev.70",
|
|
4
4
|
"description": "Prisma's driver adapter for \"pg\"",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -31,16 +31,16 @@
|
|
|
31
31
|
"license": "Apache-2.0",
|
|
32
32
|
"sideEffects": false,
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"postgres-array": "3.0.
|
|
35
|
-
"@prisma/driver-adapter-utils": "6.5.0-dev.
|
|
34
|
+
"postgres-array": "3.0.3",
|
|
35
|
+
"@prisma/driver-adapter-utils": "6.5.0-dev.70"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@swc/core": "1.
|
|
38
|
+
"@swc/core": "1.11.5",
|
|
39
39
|
"@swc/jest": "0.2.37",
|
|
40
|
-
"@types/pg": "8.11.
|
|
40
|
+
"@types/pg": "8.11.11",
|
|
41
41
|
"jest": "29.7.0",
|
|
42
42
|
"jest-junit": "16.0.0",
|
|
43
|
-
"pg": "8.
|
|
43
|
+
"pg": "8.13.3"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"pg": "^8.11.3"
|