@prisma/adapter-pg 6.15.0-dev.3 → 6.15.0-dev.5
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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +35 -15
- package/dist/index.mjs +35 -15
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -358,20 +358,35 @@ var customParsers = {
|
|
|
358
358
|
[ArrayColumnType.VARBIT_ARRAY]: normalize_array(normalizeBit),
|
|
359
359
|
[ArrayColumnType.XML_ARRAY]: normalize_array(normalize_xml)
|
|
360
360
|
};
|
|
361
|
-
function
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
361
|
+
function mapArg(arg, argType) {
|
|
362
|
+
if (arg === null) {
|
|
363
|
+
return null;
|
|
364
|
+
}
|
|
365
|
+
if (Array.isArray(arg) && argType.arity === "list") {
|
|
366
|
+
return arg.map((value) => mapArg(value, argType));
|
|
367
|
+
}
|
|
368
|
+
if (typeof arg === "string" && argType.scalarType === "datetime") {
|
|
369
|
+
arg = new Date(arg);
|
|
370
|
+
}
|
|
371
|
+
if (arg instanceof Date) {
|
|
372
|
+
switch (argType.dbType) {
|
|
373
|
+
case "TIME":
|
|
374
|
+
case "TIMETZ":
|
|
375
|
+
return arg.toISOString().split("T")[1];
|
|
376
|
+
default:
|
|
377
|
+
return arg.toISOString();
|
|
372
378
|
}
|
|
373
379
|
}
|
|
374
|
-
|
|
380
|
+
if (typeof arg === "string" && argType.scalarType === "bytes") {
|
|
381
|
+
return Buffer.from(arg, "base64");
|
|
382
|
+
}
|
|
383
|
+
if (Array.isArray(arg) && argType.scalarType === "bytes") {
|
|
384
|
+
return Buffer.from(arg);
|
|
385
|
+
}
|
|
386
|
+
if (ArrayBuffer.isView(arg)) {
|
|
387
|
+
return Buffer.from(arg.buffer, arg.byteOffset, arg.byteLength);
|
|
388
|
+
}
|
|
389
|
+
return arg;
|
|
375
390
|
}
|
|
376
391
|
|
|
377
392
|
// src/errors.ts
|
|
@@ -602,12 +617,13 @@ var PgQueryable = class {
|
|
|
602
617
|
* marked as unhealthy.
|
|
603
618
|
*/
|
|
604
619
|
async performIO(query) {
|
|
605
|
-
const { sql, args
|
|
620
|
+
const { sql, args } = query;
|
|
621
|
+
const values = args.map((arg, i) => mapArg(arg, query.argTypes[i]));
|
|
606
622
|
try {
|
|
607
623
|
const result = await this.client.query(
|
|
608
624
|
{
|
|
609
625
|
text: sql,
|
|
610
|
-
values
|
|
626
|
+
values,
|
|
611
627
|
rowMode: "array",
|
|
612
628
|
types: {
|
|
613
629
|
// This is the error expected:
|
|
@@ -630,7 +646,7 @@ var PgQueryable = class {
|
|
|
630
646
|
}
|
|
631
647
|
}
|
|
632
648
|
},
|
|
633
|
-
|
|
649
|
+
values
|
|
634
650
|
);
|
|
635
651
|
return result;
|
|
636
652
|
} catch (e) {
|
|
@@ -669,6 +685,10 @@ var PrismaPgAdapter = class extends PgQueryable {
|
|
|
669
685
|
const tag = "[js::startTransaction]";
|
|
670
686
|
debug("%s options: %O", tag, options);
|
|
671
687
|
const conn = await this.client.connect().catch((error) => this.onError(error));
|
|
688
|
+
conn.on("error", (err) => {
|
|
689
|
+
debug(`Error from pool connection: ${err.message} %O`, err);
|
|
690
|
+
this.options?.onConnectionError?.(err);
|
|
691
|
+
});
|
|
672
692
|
try {
|
|
673
693
|
const tx = new PgTransaction(conn, options);
|
|
674
694
|
await tx.executeRaw({ sql: "BEGIN", args: [], argTypes: [] });
|
package/dist/index.mjs
CHANGED
|
@@ -322,20 +322,35 @@ var customParsers = {
|
|
|
322
322
|
[ArrayColumnType.VARBIT_ARRAY]: normalize_array(normalizeBit),
|
|
323
323
|
[ArrayColumnType.XML_ARRAY]: normalize_array(normalize_xml)
|
|
324
324
|
};
|
|
325
|
-
function
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
325
|
+
function mapArg(arg, argType) {
|
|
326
|
+
if (arg === null) {
|
|
327
|
+
return null;
|
|
328
|
+
}
|
|
329
|
+
if (Array.isArray(arg) && argType.arity === "list") {
|
|
330
|
+
return arg.map((value) => mapArg(value, argType));
|
|
331
|
+
}
|
|
332
|
+
if (typeof arg === "string" && argType.scalarType === "datetime") {
|
|
333
|
+
arg = new Date(arg);
|
|
334
|
+
}
|
|
335
|
+
if (arg instanceof Date) {
|
|
336
|
+
switch (argType.dbType) {
|
|
337
|
+
case "TIME":
|
|
338
|
+
case "TIMETZ":
|
|
339
|
+
return arg.toISOString().split("T")[1];
|
|
340
|
+
default:
|
|
341
|
+
return arg.toISOString();
|
|
336
342
|
}
|
|
337
343
|
}
|
|
338
|
-
|
|
344
|
+
if (typeof arg === "string" && argType.scalarType === "bytes") {
|
|
345
|
+
return Buffer.from(arg, "base64");
|
|
346
|
+
}
|
|
347
|
+
if (Array.isArray(arg) && argType.scalarType === "bytes") {
|
|
348
|
+
return Buffer.from(arg);
|
|
349
|
+
}
|
|
350
|
+
if (ArrayBuffer.isView(arg)) {
|
|
351
|
+
return Buffer.from(arg.buffer, arg.byteOffset, arg.byteLength);
|
|
352
|
+
}
|
|
353
|
+
return arg;
|
|
339
354
|
}
|
|
340
355
|
|
|
341
356
|
// src/errors.ts
|
|
@@ -566,12 +581,13 @@ var PgQueryable = class {
|
|
|
566
581
|
* marked as unhealthy.
|
|
567
582
|
*/
|
|
568
583
|
async performIO(query) {
|
|
569
|
-
const { sql, args
|
|
584
|
+
const { sql, args } = query;
|
|
585
|
+
const values = args.map((arg, i) => mapArg(arg, query.argTypes[i]));
|
|
570
586
|
try {
|
|
571
587
|
const result = await this.client.query(
|
|
572
588
|
{
|
|
573
589
|
text: sql,
|
|
574
|
-
values
|
|
590
|
+
values,
|
|
575
591
|
rowMode: "array",
|
|
576
592
|
types: {
|
|
577
593
|
// This is the error expected:
|
|
@@ -594,7 +610,7 @@ var PgQueryable = class {
|
|
|
594
610
|
}
|
|
595
611
|
}
|
|
596
612
|
},
|
|
597
|
-
|
|
613
|
+
values
|
|
598
614
|
);
|
|
599
615
|
return result;
|
|
600
616
|
} catch (e) {
|
|
@@ -633,6 +649,10 @@ var PrismaPgAdapter = class extends PgQueryable {
|
|
|
633
649
|
const tag = "[js::startTransaction]";
|
|
634
650
|
debug("%s options: %O", tag, options);
|
|
635
651
|
const conn = await this.client.connect().catch((error) => this.onError(error));
|
|
652
|
+
conn.on("error", (err) => {
|
|
653
|
+
debug(`Error from pool connection: ${err.message} %O`, err);
|
|
654
|
+
this.options?.onConnectionError?.(err);
|
|
655
|
+
});
|
|
636
656
|
try {
|
|
637
657
|
const tx = new PgTransaction(conn, options);
|
|
638
658
|
await tx.executeRaw({ sql: "BEGIN", args: [], argTypes: [] });
|
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.5",
|
|
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.5"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@swc/core": "1.11.5",
|