@prisma/client-engine-runtime 6.11.0-dev.43 → 6.11.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/QueryPlan.d.ts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +30 -51
- package/dist/index.mjs +30 -51
- package/package.json +3 -3
package/dist/QueryPlan.d.ts
CHANGED
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -140,12 +140,12 @@ function mapObject(data, fields, enums) {
|
|
|
140
140
|
throw new DataMapperError(`Unexpected 'AffectedRows' node in data mapping for field '${name}'`);
|
|
141
141
|
}
|
|
142
142
|
case "Object": {
|
|
143
|
-
if (node.
|
|
143
|
+
if (!node.flattened && !Object.hasOwn(data, name)) {
|
|
144
144
|
throw new DataMapperError(
|
|
145
145
|
`Missing data field (Object): '${name}'; node: ${JSON.stringify(node)}; data: ${JSON.stringify(data)}`
|
|
146
146
|
);
|
|
147
147
|
}
|
|
148
|
-
const target = node.
|
|
148
|
+
const target = node.flattened ? data : data[name];
|
|
149
149
|
result[name] = mapArrayOrObject(target, node.fields, enums);
|
|
150
150
|
break;
|
|
151
151
|
}
|
|
@@ -230,12 +230,6 @@ function mapValue(value, columnName, resultType, enums) {
|
|
|
230
230
|
throw new DataMapperError(`Expected a boolean in column '${columnName}', got ${typeof value}: ${value}`);
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
|
-
if (value instanceof Uint8Array) {
|
|
234
|
-
for (const byte of value) {
|
|
235
|
-
if (byte !== 0) return true;
|
|
236
|
-
}
|
|
237
|
-
return false;
|
|
238
|
-
}
|
|
239
233
|
throw new DataMapperError(`Expected a boolean in column '${columnName}', got ${typeof value}: ${value}`);
|
|
240
234
|
}
|
|
241
235
|
case "Decimal":
|
|
@@ -273,9 +267,6 @@ function mapValue(value, columnName, resultType, enums) {
|
|
|
273
267
|
if (Array.isArray(value)) {
|
|
274
268
|
return { $type: "Bytes", value: Buffer.from(value).toString("base64") };
|
|
275
269
|
}
|
|
276
|
-
if (value instanceof Uint8Array) {
|
|
277
|
-
return { $type: "Bytes", value: Buffer.from(value).toString("base64") };
|
|
278
|
-
}
|
|
279
270
|
throw new DataMapperError(`Expected a byte array in column '${columnName}', got ${typeof value}: ${value}`);
|
|
280
271
|
}
|
|
281
272
|
case "Enum": {
|
|
@@ -477,7 +468,7 @@ function renderErrorMessage(err) {
|
|
|
477
468
|
case "NullConstraintViolation":
|
|
478
469
|
return `Null constraint violation on the ${renderConstraint(err.cause.constraint)}`;
|
|
479
470
|
case "ValueOutOfRange":
|
|
480
|
-
return `Value out of range for the type
|
|
471
|
+
return `Value out of range for the type. ${err.cause.cause}`;
|
|
481
472
|
case "TableDoesNotExist": {
|
|
482
473
|
const table = err.cause.table ?? "(not available)";
|
|
483
474
|
return `The table \`${table}\` does not exist in the current database.`;
|
|
@@ -773,16 +764,8 @@ function doesRequireEvaluation(param) {
|
|
|
773
764
|
// src/interpreter/serializeSql.ts
|
|
774
765
|
var import_driver_adapter_utils2 = require("@prisma/driver-adapter-utils");
|
|
775
766
|
function serializeSql(resultSet) {
|
|
776
|
-
const mappers = resultSet.columnTypes.map((type) => {
|
|
777
|
-
switch (type) {
|
|
778
|
-
case import_driver_adapter_utils2.ColumnTypeEnum.Bytes:
|
|
779
|
-
return (value) => Array.isArray(value) ? new Uint8Array(value) : value;
|
|
780
|
-
default:
|
|
781
|
-
return (value) => value;
|
|
782
|
-
}
|
|
783
|
-
});
|
|
784
767
|
return resultSet.rows.map(
|
|
785
|
-
(row) => row.
|
|
768
|
+
(row) => row.reduce((acc, value, index) => {
|
|
786
769
|
const splitByDot = resultSet.columnNames[index].split(".");
|
|
787
770
|
let nested = acc;
|
|
788
771
|
for (let i = 0; i < splitByDot.length; i++) {
|
|
@@ -804,8 +787,6 @@ function serializeRawSql(resultSet) {
|
|
|
804
787
|
const types = resultSet.columnTypes.map((type) => serializeColumnType(type));
|
|
805
788
|
const mappers = types.map((type) => {
|
|
806
789
|
switch (type) {
|
|
807
|
-
case "bytes":
|
|
808
|
-
return (value) => Array.isArray(value) ? new Uint8Array(value) : value;
|
|
809
790
|
case "int":
|
|
810
791
|
return (value) => value === null ? null : typeof value === "number" ? value : parseInt(`${value}`, 10);
|
|
811
792
|
case "bigint":
|
|
@@ -1443,16 +1424,17 @@ var TransactionManager = class {
|
|
|
1443
1424
|
transaction: void 0
|
|
1444
1425
|
};
|
|
1445
1426
|
this.transactions.set(transaction.id, transaction);
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
clearTimeout(startTimer);
|
|
1427
|
+
transaction.timer = this.startTransactionTimeout(transaction.id, validatedOptions.maxWait);
|
|
1428
|
+
const startedTransaction = await this.driverAdapter.startTransaction(validatedOptions.isolationLevel);
|
|
1449
1429
|
switch (transaction.status) {
|
|
1450
1430
|
case "waiting":
|
|
1431
|
+
transaction.transaction = startedTransaction;
|
|
1432
|
+
clearTimeout(transaction.timer);
|
|
1433
|
+
transaction.timer = void 0;
|
|
1451
1434
|
transaction.status = "running";
|
|
1452
1435
|
transaction.timer = this.startTransactionTimeout(transaction.id, validatedOptions.timeout);
|
|
1453
1436
|
return { id: transaction.id };
|
|
1454
1437
|
case "timed_out":
|
|
1455
|
-
await this.closeTransaction(transaction, "timed_out");
|
|
1456
1438
|
throw new TransactionStartTimeoutError();
|
|
1457
1439
|
case "running":
|
|
1458
1440
|
case "committed":
|
|
@@ -1529,33 +1511,30 @@ var TransactionManager = class {
|
|
|
1529
1511
|
async closeTransaction(tx, status) {
|
|
1530
1512
|
debug("Closing transaction.", { transactionId: tx.id, status });
|
|
1531
1513
|
tx.status = status;
|
|
1532
|
-
|
|
1533
|
-
if (tx.transaction
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
await tx.transaction.commit();
|
|
1540
|
-
}
|
|
1541
|
-
} else if (tx.transaction) {
|
|
1542
|
-
if (tx.transaction.options.usePhantomQuery) {
|
|
1543
|
-
await this.#withQuerySpanAndEvent(PHANTOM_ROLLBACK_QUERY(), tx.transaction, () => tx.transaction.rollback());
|
|
1544
|
-
} else {
|
|
1545
|
-
const query = ROLLBACK_QUERY();
|
|
1546
|
-
await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query));
|
|
1547
|
-
await tx.transaction.rollback();
|
|
1548
|
-
}
|
|
1514
|
+
if (tx.transaction && status === "committed") {
|
|
1515
|
+
if (tx.transaction.options.usePhantomQuery) {
|
|
1516
|
+
await this.#withQuerySpanAndEvent(PHANTOM_COMMIT_QUERY(), tx.transaction, () => tx.transaction.commit());
|
|
1517
|
+
} else {
|
|
1518
|
+
await tx.transaction.commit();
|
|
1519
|
+
const query = COMMIT_QUERY();
|
|
1520
|
+
await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query));
|
|
1549
1521
|
}
|
|
1550
|
-
}
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
this.
|
|
1522
|
+
} else if (tx.transaction) {
|
|
1523
|
+
if (tx.transaction.options.usePhantomQuery) {
|
|
1524
|
+
await this.#withQuerySpanAndEvent(PHANTOM_ROLLBACK_QUERY(), tx.transaction, () => tx.transaction.rollback());
|
|
1525
|
+
} else {
|
|
1526
|
+
await tx.transaction.rollback();
|
|
1527
|
+
const query = ROLLBACK_QUERY();
|
|
1528
|
+
await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query));
|
|
1557
1529
|
}
|
|
1558
1530
|
}
|
|
1531
|
+
clearTimeout(tx.timer);
|
|
1532
|
+
tx.timer = void 0;
|
|
1533
|
+
this.transactions.delete(tx.id);
|
|
1534
|
+
this.closedTransactions.push(tx);
|
|
1535
|
+
if (this.closedTransactions.length > MAX_CLOSED_TRANSACTIONS) {
|
|
1536
|
+
this.closedTransactions.shift();
|
|
1537
|
+
}
|
|
1559
1538
|
}
|
|
1560
1539
|
validateOptions(options) {
|
|
1561
1540
|
if (!options.timeout) throw new TransactionManagerError("timeout is required");
|
package/dist/index.mjs
CHANGED
|
@@ -92,12 +92,12 @@ function mapObject(data, fields, enums) {
|
|
|
92
92
|
throw new DataMapperError(`Unexpected 'AffectedRows' node in data mapping for field '${name}'`);
|
|
93
93
|
}
|
|
94
94
|
case "Object": {
|
|
95
|
-
if (node.
|
|
95
|
+
if (!node.flattened && !Object.hasOwn(data, name)) {
|
|
96
96
|
throw new DataMapperError(
|
|
97
97
|
`Missing data field (Object): '${name}'; node: ${JSON.stringify(node)}; data: ${JSON.stringify(data)}`
|
|
98
98
|
);
|
|
99
99
|
}
|
|
100
|
-
const target = node.
|
|
100
|
+
const target = node.flattened ? data : data[name];
|
|
101
101
|
result[name] = mapArrayOrObject(target, node.fields, enums);
|
|
102
102
|
break;
|
|
103
103
|
}
|
|
@@ -182,12 +182,6 @@ function mapValue(value, columnName, resultType, enums) {
|
|
|
182
182
|
throw new DataMapperError(`Expected a boolean in column '${columnName}', got ${typeof value}: ${value}`);
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
-
if (value instanceof Uint8Array) {
|
|
186
|
-
for (const byte of value) {
|
|
187
|
-
if (byte !== 0) return true;
|
|
188
|
-
}
|
|
189
|
-
return false;
|
|
190
|
-
}
|
|
191
185
|
throw new DataMapperError(`Expected a boolean in column '${columnName}', got ${typeof value}: ${value}`);
|
|
192
186
|
}
|
|
193
187
|
case "Decimal":
|
|
@@ -225,9 +219,6 @@ function mapValue(value, columnName, resultType, enums) {
|
|
|
225
219
|
if (Array.isArray(value)) {
|
|
226
220
|
return { $type: "Bytes", value: Buffer.from(value).toString("base64") };
|
|
227
221
|
}
|
|
228
|
-
if (value instanceof Uint8Array) {
|
|
229
|
-
return { $type: "Bytes", value: Buffer.from(value).toString("base64") };
|
|
230
|
-
}
|
|
231
222
|
throw new DataMapperError(`Expected a byte array in column '${columnName}', got ${typeof value}: ${value}`);
|
|
232
223
|
}
|
|
233
224
|
case "Enum": {
|
|
@@ -429,7 +420,7 @@ function renderErrorMessage(err) {
|
|
|
429
420
|
case "NullConstraintViolation":
|
|
430
421
|
return `Null constraint violation on the ${renderConstraint(err.cause.constraint)}`;
|
|
431
422
|
case "ValueOutOfRange":
|
|
432
|
-
return `Value out of range for the type
|
|
423
|
+
return `Value out of range for the type. ${err.cause.cause}`;
|
|
433
424
|
case "TableDoesNotExist": {
|
|
434
425
|
const table = err.cause.table ?? "(not available)";
|
|
435
426
|
return `The table \`${table}\` does not exist in the current database.`;
|
|
@@ -725,16 +716,8 @@ function doesRequireEvaluation(param) {
|
|
|
725
716
|
// src/interpreter/serializeSql.ts
|
|
726
717
|
import { ColumnTypeEnum } from "@prisma/driver-adapter-utils";
|
|
727
718
|
function serializeSql(resultSet) {
|
|
728
|
-
const mappers = resultSet.columnTypes.map((type) => {
|
|
729
|
-
switch (type) {
|
|
730
|
-
case ColumnTypeEnum.Bytes:
|
|
731
|
-
return (value) => Array.isArray(value) ? new Uint8Array(value) : value;
|
|
732
|
-
default:
|
|
733
|
-
return (value) => value;
|
|
734
|
-
}
|
|
735
|
-
});
|
|
736
719
|
return resultSet.rows.map(
|
|
737
|
-
(row) => row.
|
|
720
|
+
(row) => row.reduce((acc, value, index) => {
|
|
738
721
|
const splitByDot = resultSet.columnNames[index].split(".");
|
|
739
722
|
let nested = acc;
|
|
740
723
|
for (let i = 0; i < splitByDot.length; i++) {
|
|
@@ -756,8 +739,6 @@ function serializeRawSql(resultSet) {
|
|
|
756
739
|
const types = resultSet.columnTypes.map((type) => serializeColumnType(type));
|
|
757
740
|
const mappers = types.map((type) => {
|
|
758
741
|
switch (type) {
|
|
759
|
-
case "bytes":
|
|
760
|
-
return (value) => Array.isArray(value) ? new Uint8Array(value) : value;
|
|
761
742
|
case "int":
|
|
762
743
|
return (value) => value === null ? null : typeof value === "number" ? value : parseInt(`${value}`, 10);
|
|
763
744
|
case "bigint":
|
|
@@ -1395,16 +1376,17 @@ var TransactionManager = class {
|
|
|
1395
1376
|
transaction: void 0
|
|
1396
1377
|
};
|
|
1397
1378
|
this.transactions.set(transaction.id, transaction);
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
clearTimeout(startTimer);
|
|
1379
|
+
transaction.timer = this.startTransactionTimeout(transaction.id, validatedOptions.maxWait);
|
|
1380
|
+
const startedTransaction = await this.driverAdapter.startTransaction(validatedOptions.isolationLevel);
|
|
1401
1381
|
switch (transaction.status) {
|
|
1402
1382
|
case "waiting":
|
|
1383
|
+
transaction.transaction = startedTransaction;
|
|
1384
|
+
clearTimeout(transaction.timer);
|
|
1385
|
+
transaction.timer = void 0;
|
|
1403
1386
|
transaction.status = "running";
|
|
1404
1387
|
transaction.timer = this.startTransactionTimeout(transaction.id, validatedOptions.timeout);
|
|
1405
1388
|
return { id: transaction.id };
|
|
1406
1389
|
case "timed_out":
|
|
1407
|
-
await this.closeTransaction(transaction, "timed_out");
|
|
1408
1390
|
throw new TransactionStartTimeoutError();
|
|
1409
1391
|
case "running":
|
|
1410
1392
|
case "committed":
|
|
@@ -1481,33 +1463,30 @@ var TransactionManager = class {
|
|
|
1481
1463
|
async closeTransaction(tx, status) {
|
|
1482
1464
|
debug("Closing transaction.", { transactionId: tx.id, status });
|
|
1483
1465
|
tx.status = status;
|
|
1484
|
-
|
|
1485
|
-
if (tx.transaction
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
await tx.transaction.commit();
|
|
1492
|
-
}
|
|
1493
|
-
} else if (tx.transaction) {
|
|
1494
|
-
if (tx.transaction.options.usePhantomQuery) {
|
|
1495
|
-
await this.#withQuerySpanAndEvent(PHANTOM_ROLLBACK_QUERY(), tx.transaction, () => tx.transaction.rollback());
|
|
1496
|
-
} else {
|
|
1497
|
-
const query = ROLLBACK_QUERY();
|
|
1498
|
-
await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query));
|
|
1499
|
-
await tx.transaction.rollback();
|
|
1500
|
-
}
|
|
1466
|
+
if (tx.transaction && status === "committed") {
|
|
1467
|
+
if (tx.transaction.options.usePhantomQuery) {
|
|
1468
|
+
await this.#withQuerySpanAndEvent(PHANTOM_COMMIT_QUERY(), tx.transaction, () => tx.transaction.commit());
|
|
1469
|
+
} else {
|
|
1470
|
+
await tx.transaction.commit();
|
|
1471
|
+
const query = COMMIT_QUERY();
|
|
1472
|
+
await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query));
|
|
1501
1473
|
}
|
|
1502
|
-
}
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
this.
|
|
1474
|
+
} else if (tx.transaction) {
|
|
1475
|
+
if (tx.transaction.options.usePhantomQuery) {
|
|
1476
|
+
await this.#withQuerySpanAndEvent(PHANTOM_ROLLBACK_QUERY(), tx.transaction, () => tx.transaction.rollback());
|
|
1477
|
+
} else {
|
|
1478
|
+
await tx.transaction.rollback();
|
|
1479
|
+
const query = ROLLBACK_QUERY();
|
|
1480
|
+
await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query));
|
|
1509
1481
|
}
|
|
1510
1482
|
}
|
|
1483
|
+
clearTimeout(tx.timer);
|
|
1484
|
+
tx.timer = void 0;
|
|
1485
|
+
this.transactions.delete(tx.id);
|
|
1486
|
+
this.closedTransactions.push(tx);
|
|
1487
|
+
if (this.closedTransactions.length > MAX_CLOSED_TRANSACTIONS) {
|
|
1488
|
+
this.closedTransactions.shift();
|
|
1489
|
+
}
|
|
1511
1490
|
}
|
|
1512
1491
|
validateOptions(options) {
|
|
1513
1492
|
if (!options.timeout) throw new TransactionManagerError("timeout is required");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/client-engine-runtime",
|
|
3
|
-
"version": "6.11.0-dev.
|
|
3
|
+
"version": "6.11.0-dev.5",
|
|
4
4
|
"description": "This package is intended for Prisma's internal use",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"nanoid": "5.1.5",
|
|
32
32
|
"ulid": "3.0.0",
|
|
33
33
|
"uuid": "11.1.0",
|
|
34
|
-
"@prisma/debug": "6.11.0-dev.
|
|
35
|
-
"@prisma/driver-adapter-utils": "6.11.0-dev.
|
|
34
|
+
"@prisma/debug": "6.11.0-dev.5",
|
|
35
|
+
"@prisma/driver-adapter-utils": "6.11.0-dev.5"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/jest": "29.5.14",
|