@prisma/adapter-pg 7.2.0 → 7.3.0-integration-prisma6-fix-cloudflare-engine.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/README.md +1 -1
- package/dist/index.js +14 -12
- package/dist/index.mjs +14 -12
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This package contains the driver adapter for Prisma ORM that enables usage of th
|
|
|
8
8
|
|
|
9
9
|
## Usage
|
|
10
10
|
|
|
11
|
-
This section explains how you can use it with Prisma ORM and the `@prisma/adapter-pg` driver adapter. Be sure that the `DATABASE_URL` environment variable is set to your PostgreSQL connection string (e.g.
|
|
11
|
+
This section explains how you can use it with Prisma ORM and the `@prisma/adapter-pg` driver adapter. Be sure that the `DATABASE_URL` environment variable is set to your PostgreSQL connection string (e.g. in a `.env` file).
|
|
12
12
|
|
|
13
13
|
### 1. Install the dependencies
|
|
14
14
|
|
package/dist/index.js
CHANGED
|
@@ -50,9 +50,6 @@ var import_pg = __toESM(require("pg"));
|
|
|
50
50
|
var import_postgres_array = require("postgres-array");
|
|
51
51
|
var { types } = import_pg.default;
|
|
52
52
|
var { builtins: ScalarColumnType, getTypeParser } = types;
|
|
53
|
-
var AdditionalScalarColumnType = {
|
|
54
|
-
NAME: 19
|
|
55
|
-
};
|
|
56
53
|
var ArrayColumnType = {
|
|
57
54
|
BIT_ARRAY: 1561,
|
|
58
55
|
BOOL_ARRAY: 1e3,
|
|
@@ -243,7 +240,6 @@ function fieldToColumnType(fieldTypeId) {
|
|
|
243
240
|
case ScalarColumnType.INET:
|
|
244
241
|
case ScalarColumnType.CIDR:
|
|
245
242
|
case ScalarColumnType.XML:
|
|
246
|
-
case AdditionalScalarColumnType.NAME:
|
|
247
243
|
return import_driver_adapter_utils.ColumnTypeEnum.Text;
|
|
248
244
|
case ScalarColumnType.BYTEA:
|
|
249
245
|
return import_driver_adapter_utils.ColumnTypeEnum.Bytes;
|
|
@@ -325,10 +321,18 @@ function normalize_xml(xml) {
|
|
|
325
321
|
function toJson(json) {
|
|
326
322
|
return json;
|
|
327
323
|
}
|
|
324
|
+
function encodeBuffer(buffer) {
|
|
325
|
+
return Array.from(new Uint8Array(buffer));
|
|
326
|
+
}
|
|
328
327
|
var parsePgBytes = getTypeParser(ScalarColumnType.BYTEA);
|
|
329
|
-
var
|
|
328
|
+
var parseBytesArray = getTypeParser(ArrayColumnType.BYTEA_ARRAY);
|
|
329
|
+
function normalizeByteaArray(serializedBytesArray) {
|
|
330
|
+
const buffers = parseBytesArray(serializedBytesArray);
|
|
331
|
+
return buffers.map((buf) => buf ? encodeBuffer(buf) : null);
|
|
332
|
+
}
|
|
330
333
|
function convertBytes(serializedBytes) {
|
|
331
|
-
|
|
334
|
+
const buffer = parsePgBytes(serializedBytes);
|
|
335
|
+
return encodeBuffer(buffer);
|
|
332
336
|
}
|
|
333
337
|
function normalizeBit(bit) {
|
|
334
338
|
return bit;
|
|
@@ -381,8 +385,11 @@ function mapArg(arg, argType) {
|
|
|
381
385
|
if (typeof arg === "string" && argType.scalarType === "bytes") {
|
|
382
386
|
return Buffer.from(arg, "base64");
|
|
383
387
|
}
|
|
388
|
+
if (Array.isArray(arg) && argType.scalarType === "bytes") {
|
|
389
|
+
return Buffer.from(arg);
|
|
390
|
+
}
|
|
384
391
|
if (ArrayBuffer.isView(arg)) {
|
|
385
|
-
return
|
|
392
|
+
return Buffer.from(arg.buffer, arg.byteOffset, arg.byteLength);
|
|
386
393
|
}
|
|
387
394
|
return arg;
|
|
388
395
|
}
|
|
@@ -464,11 +471,6 @@ function mapDriverError(error) {
|
|
|
464
471
|
kind: "ValueOutOfRange",
|
|
465
472
|
cause: error.message
|
|
466
473
|
};
|
|
467
|
-
case "22P02":
|
|
468
|
-
return {
|
|
469
|
-
kind: "InvalidInputValue",
|
|
470
|
-
message: error.message
|
|
471
|
-
};
|
|
472
474
|
case "23505": {
|
|
473
475
|
const fields = error.detail?.match(/Key \(([^)]+)\)/)?.at(1)?.split(", ");
|
|
474
476
|
return {
|
package/dist/index.mjs
CHANGED
|
@@ -14,9 +14,6 @@ import pg from "pg";
|
|
|
14
14
|
import { parse as parseArray } from "postgres-array";
|
|
15
15
|
var { types } = pg;
|
|
16
16
|
var { builtins: ScalarColumnType, getTypeParser } = types;
|
|
17
|
-
var AdditionalScalarColumnType = {
|
|
18
|
-
NAME: 19
|
|
19
|
-
};
|
|
20
17
|
var ArrayColumnType = {
|
|
21
18
|
BIT_ARRAY: 1561,
|
|
22
19
|
BOOL_ARRAY: 1e3,
|
|
@@ -207,7 +204,6 @@ function fieldToColumnType(fieldTypeId) {
|
|
|
207
204
|
case ScalarColumnType.INET:
|
|
208
205
|
case ScalarColumnType.CIDR:
|
|
209
206
|
case ScalarColumnType.XML:
|
|
210
|
-
case AdditionalScalarColumnType.NAME:
|
|
211
207
|
return ColumnTypeEnum.Text;
|
|
212
208
|
case ScalarColumnType.BYTEA:
|
|
213
209
|
return ColumnTypeEnum.Bytes;
|
|
@@ -289,10 +285,18 @@ function normalize_xml(xml) {
|
|
|
289
285
|
function toJson(json) {
|
|
290
286
|
return json;
|
|
291
287
|
}
|
|
288
|
+
function encodeBuffer(buffer) {
|
|
289
|
+
return Array.from(new Uint8Array(buffer));
|
|
290
|
+
}
|
|
292
291
|
var parsePgBytes = getTypeParser(ScalarColumnType.BYTEA);
|
|
293
|
-
var
|
|
292
|
+
var parseBytesArray = getTypeParser(ArrayColumnType.BYTEA_ARRAY);
|
|
293
|
+
function normalizeByteaArray(serializedBytesArray) {
|
|
294
|
+
const buffers = parseBytesArray(serializedBytesArray);
|
|
295
|
+
return buffers.map((buf) => buf ? encodeBuffer(buf) : null);
|
|
296
|
+
}
|
|
294
297
|
function convertBytes(serializedBytes) {
|
|
295
|
-
|
|
298
|
+
const buffer = parsePgBytes(serializedBytes);
|
|
299
|
+
return encodeBuffer(buffer);
|
|
296
300
|
}
|
|
297
301
|
function normalizeBit(bit) {
|
|
298
302
|
return bit;
|
|
@@ -345,8 +349,11 @@ function mapArg(arg, argType) {
|
|
|
345
349
|
if (typeof arg === "string" && argType.scalarType === "bytes") {
|
|
346
350
|
return Buffer.from(arg, "base64");
|
|
347
351
|
}
|
|
352
|
+
if (Array.isArray(arg) && argType.scalarType === "bytes") {
|
|
353
|
+
return Buffer.from(arg);
|
|
354
|
+
}
|
|
348
355
|
if (ArrayBuffer.isView(arg)) {
|
|
349
|
-
return
|
|
356
|
+
return Buffer.from(arg.buffer, arg.byteOffset, arg.byteLength);
|
|
350
357
|
}
|
|
351
358
|
return arg;
|
|
352
359
|
}
|
|
@@ -428,11 +435,6 @@ function mapDriverError(error) {
|
|
|
428
435
|
kind: "ValueOutOfRange",
|
|
429
436
|
cause: error.message
|
|
430
437
|
};
|
|
431
|
-
case "22P02":
|
|
432
|
-
return {
|
|
433
|
-
kind: "InvalidInputValue",
|
|
434
|
-
message: error.message
|
|
435
|
-
};
|
|
436
438
|
case "23505": {
|
|
437
439
|
const fields = error.detail?.match(/Key \(([^)]+)\)/)?.at(1)?.split(", ");
|
|
438
440
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/adapter-pg",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.0-integration-prisma6-fix-cloudflare-engine.1",
|
|
4
4
|
"description": "Prisma's driver adapter for \"pg\"",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"license": "Apache-2.0",
|
|
32
32
|
"sideEffects": false,
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"pg": "^8.16.3",
|
|
35
34
|
"postgres-array": "3.0.4",
|
|
36
|
-
"
|
|
35
|
+
"pg": "^8.11.3",
|
|
36
|
+
"@prisma/driver-adapter-utils": "7.3.0-integration-prisma6-fix-cloudflare-engine.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/pg": "8.11.11",
|
|
40
|
-
"@prisma/debug": "7.
|
|
40
|
+
"@prisma/debug": "7.3.0-integration-prisma6-fix-cloudflare-engine.1"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"dev": "DEV=true tsx helpers/build.ts",
|