@prisma/client-engine-runtime 6.11.0-dev.1 → 6.11.0-dev.10
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.js +66 -53
- package/dist/index.mjs +66 -53
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -267,6 +267,9 @@ function mapValue(value, columnName, resultType, enums) {
|
|
|
267
267
|
if (Array.isArray(value)) {
|
|
268
268
|
return { $type: "Bytes", value: Buffer.from(value).toString("base64") };
|
|
269
269
|
}
|
|
270
|
+
if (value instanceof Uint8Array) {
|
|
271
|
+
return { $type: "Bytes", value: Buffer.from(value).toString("base64") };
|
|
272
|
+
}
|
|
270
273
|
throw new DataMapperError(`Expected a byte array in column '${columnName}', got ${typeof value}: ${value}`);
|
|
271
274
|
}
|
|
272
275
|
case "Enum": {
|
|
@@ -764,8 +767,16 @@ function doesRequireEvaluation(param) {
|
|
|
764
767
|
// src/interpreter/serializeSql.ts
|
|
765
768
|
var import_driver_adapter_utils2 = require("@prisma/driver-adapter-utils");
|
|
766
769
|
function serializeSql(resultSet) {
|
|
770
|
+
const mappers = resultSet.columnTypes.map((type) => {
|
|
771
|
+
switch (type) {
|
|
772
|
+
case import_driver_adapter_utils2.ColumnTypeEnum.Bytes:
|
|
773
|
+
return (value) => Array.isArray(value) ? new Uint8Array(value) : value;
|
|
774
|
+
default:
|
|
775
|
+
return (value) => value;
|
|
776
|
+
}
|
|
777
|
+
});
|
|
767
778
|
return resultSet.rows.map(
|
|
768
|
-
(row) => row.reduce((acc, value, index) => {
|
|
779
|
+
(row) => row.map((value, index) => mappers[index](value)).reduce((acc, value, index) => {
|
|
769
780
|
const splitByDot = resultSet.columnNames[index].split(".");
|
|
770
781
|
let nested = acc;
|
|
771
782
|
for (let i = 0; i < splitByDot.length; i++) {
|
|
@@ -1093,13 +1104,7 @@ var QueryInterpreter = class _QueryInterpreter {
|
|
|
1093
1104
|
childRecords: (await this.interpretNode(joinExpr.child, queryable, scope, generators)).value
|
|
1094
1105
|
}))
|
|
1095
1106
|
);
|
|
1096
|
-
|
|
1097
|
-
for (const record of parent) {
|
|
1098
|
-
attachChildrenToParent(asRecord(record), children);
|
|
1099
|
-
}
|
|
1100
|
-
return { value: parent, lastInsertId };
|
|
1101
|
-
}
|
|
1102
|
-
return { value: attachChildrenToParent(asRecord(parent), children), lastInsertId };
|
|
1107
|
+
return { value: attachChildrenToParents(parent, children), lastInsertId };
|
|
1103
1108
|
}
|
|
1104
1109
|
case "transaction": {
|
|
1105
1110
|
if (!this.#transactionManager.enabled) {
|
|
@@ -1241,34 +1246,39 @@ function mapField(value, field) {
|
|
|
1241
1246
|
}
|
|
1242
1247
|
return value;
|
|
1243
1248
|
}
|
|
1244
|
-
function
|
|
1249
|
+
function attachChildrenToParents(parentRecords, children) {
|
|
1245
1250
|
for (const { joinExpr, childRecords } of children) {
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1251
|
+
const parentKeys = joinExpr.on.map(([k]) => k);
|
|
1252
|
+
const childKeys = joinExpr.on.map(([, k]) => k);
|
|
1253
|
+
const parentMap = {};
|
|
1254
|
+
for (const parent of Array.isArray(parentRecords) ? parentRecords : [parentRecords]) {
|
|
1255
|
+
const parentRecord = asRecord(parent);
|
|
1256
|
+
const key = getRecordKey(parentRecord, parentKeys);
|
|
1257
|
+
if (!parentMap[key]) {
|
|
1258
|
+
parentMap[key] = [];
|
|
1259
|
+
}
|
|
1260
|
+
parentMap[key].push(parentRecord);
|
|
1261
|
+
if (joinExpr.isRelationUnique) {
|
|
1262
|
+
parentRecord[joinExpr.parentField] = null;
|
|
1263
|
+
} else {
|
|
1264
|
+
parentRecord[joinExpr.parentField] = [];
|
|
1265
|
+
}
|
|
1257
1266
|
}
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1267
|
+
for (const childRecord of Array.isArray(childRecords) ? childRecords : [childRecords]) {
|
|
1268
|
+
if (childRecord === null) {
|
|
1269
|
+
continue;
|
|
1270
|
+
}
|
|
1271
|
+
const key = getRecordKey(asRecord(childRecord), childKeys);
|
|
1272
|
+
for (const parentRecord of parentMap[key] ?? []) {
|
|
1273
|
+
if (joinExpr.isRelationUnique) {
|
|
1274
|
+
parentRecord[joinExpr.parentField] = childRecord;
|
|
1275
|
+
} else {
|
|
1276
|
+
parentRecord[joinExpr.parentField].push(childRecord);
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1269
1279
|
}
|
|
1270
1280
|
}
|
|
1271
|
-
return
|
|
1281
|
+
return parentRecords;
|
|
1272
1282
|
}
|
|
1273
1283
|
function paginate(list, { cursor, skip, take }) {
|
|
1274
1284
|
const cursorIndex = cursor !== null ? list.findIndex((item) => doKeysMatch(item, cursor)) : 0;
|
|
@@ -1512,30 +1522,33 @@ var TransactionManager = class {
|
|
|
1512
1522
|
async closeTransaction(tx, status) {
|
|
1513
1523
|
debug("Closing transaction.", { transactionId: tx.id, status });
|
|
1514
1524
|
tx.status = status;
|
|
1515
|
-
|
|
1516
|
-
if (tx.transaction
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1525
|
+
try {
|
|
1526
|
+
if (tx.transaction && status === "committed") {
|
|
1527
|
+
if (tx.transaction.options.usePhantomQuery) {
|
|
1528
|
+
await this.#withQuerySpanAndEvent(PHANTOM_COMMIT_QUERY(), tx.transaction, () => tx.transaction.commit());
|
|
1529
|
+
} else {
|
|
1530
|
+
const query = COMMIT_QUERY();
|
|
1531
|
+
await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query));
|
|
1532
|
+
await tx.transaction.commit();
|
|
1533
|
+
}
|
|
1534
|
+
} else if (tx.transaction) {
|
|
1535
|
+
if (tx.transaction.options.usePhantomQuery) {
|
|
1536
|
+
await this.#withQuerySpanAndEvent(PHANTOM_ROLLBACK_QUERY(), tx.transaction, () => tx.transaction.rollback());
|
|
1537
|
+
} else {
|
|
1538
|
+
const query = ROLLBACK_QUERY();
|
|
1539
|
+
await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query));
|
|
1540
|
+
await tx.transaction.rollback();
|
|
1541
|
+
}
|
|
1522
1542
|
}
|
|
1523
|
-
}
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1543
|
+
} finally {
|
|
1544
|
+
clearTimeout(tx.timer);
|
|
1545
|
+
tx.timer = void 0;
|
|
1546
|
+
this.transactions.delete(tx.id);
|
|
1547
|
+
this.closedTransactions.push(tx);
|
|
1548
|
+
if (this.closedTransactions.length > MAX_CLOSED_TRANSACTIONS) {
|
|
1549
|
+
this.closedTransactions.shift();
|
|
1530
1550
|
}
|
|
1531
1551
|
}
|
|
1532
|
-
clearTimeout(tx.timer);
|
|
1533
|
-
tx.timer = void 0;
|
|
1534
|
-
this.transactions.delete(tx.id);
|
|
1535
|
-
this.closedTransactions.push(tx);
|
|
1536
|
-
if (this.closedTransactions.length > MAX_CLOSED_TRANSACTIONS) {
|
|
1537
|
-
this.closedTransactions.shift();
|
|
1538
|
-
}
|
|
1539
1552
|
}
|
|
1540
1553
|
validateOptions(options) {
|
|
1541
1554
|
if (!options.timeout) throw new TransactionManagerError("timeout is required");
|
package/dist/index.mjs
CHANGED
|
@@ -219,6 +219,9 @@ function mapValue(value, columnName, resultType, enums) {
|
|
|
219
219
|
if (Array.isArray(value)) {
|
|
220
220
|
return { $type: "Bytes", value: Buffer.from(value).toString("base64") };
|
|
221
221
|
}
|
|
222
|
+
if (value instanceof Uint8Array) {
|
|
223
|
+
return { $type: "Bytes", value: Buffer.from(value).toString("base64") };
|
|
224
|
+
}
|
|
222
225
|
throw new DataMapperError(`Expected a byte array in column '${columnName}', got ${typeof value}: ${value}`);
|
|
223
226
|
}
|
|
224
227
|
case "Enum": {
|
|
@@ -716,8 +719,16 @@ function doesRequireEvaluation(param) {
|
|
|
716
719
|
// src/interpreter/serializeSql.ts
|
|
717
720
|
import { ColumnTypeEnum } from "@prisma/driver-adapter-utils";
|
|
718
721
|
function serializeSql(resultSet) {
|
|
722
|
+
const mappers = resultSet.columnTypes.map((type) => {
|
|
723
|
+
switch (type) {
|
|
724
|
+
case ColumnTypeEnum.Bytes:
|
|
725
|
+
return (value) => Array.isArray(value) ? new Uint8Array(value) : value;
|
|
726
|
+
default:
|
|
727
|
+
return (value) => value;
|
|
728
|
+
}
|
|
729
|
+
});
|
|
719
730
|
return resultSet.rows.map(
|
|
720
|
-
(row) => row.reduce((acc, value, index) => {
|
|
731
|
+
(row) => row.map((value, index) => mappers[index](value)).reduce((acc, value, index) => {
|
|
721
732
|
const splitByDot = resultSet.columnNames[index].split(".");
|
|
722
733
|
let nested = acc;
|
|
723
734
|
for (let i = 0; i < splitByDot.length; i++) {
|
|
@@ -1045,13 +1056,7 @@ var QueryInterpreter = class _QueryInterpreter {
|
|
|
1045
1056
|
childRecords: (await this.interpretNode(joinExpr.child, queryable, scope, generators)).value
|
|
1046
1057
|
}))
|
|
1047
1058
|
);
|
|
1048
|
-
|
|
1049
|
-
for (const record of parent) {
|
|
1050
|
-
attachChildrenToParent(asRecord(record), children);
|
|
1051
|
-
}
|
|
1052
|
-
return { value: parent, lastInsertId };
|
|
1053
|
-
}
|
|
1054
|
-
return { value: attachChildrenToParent(asRecord(parent), children), lastInsertId };
|
|
1059
|
+
return { value: attachChildrenToParents(parent, children), lastInsertId };
|
|
1055
1060
|
}
|
|
1056
1061
|
case "transaction": {
|
|
1057
1062
|
if (!this.#transactionManager.enabled) {
|
|
@@ -1193,34 +1198,39 @@ function mapField(value, field) {
|
|
|
1193
1198
|
}
|
|
1194
1199
|
return value;
|
|
1195
1200
|
}
|
|
1196
|
-
function
|
|
1201
|
+
function attachChildrenToParents(parentRecords, children) {
|
|
1197
1202
|
for (const { joinExpr, childRecords } of children) {
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1203
|
+
const parentKeys = joinExpr.on.map(([k]) => k);
|
|
1204
|
+
const childKeys = joinExpr.on.map(([, k]) => k);
|
|
1205
|
+
const parentMap = {};
|
|
1206
|
+
for (const parent of Array.isArray(parentRecords) ? parentRecords : [parentRecords]) {
|
|
1207
|
+
const parentRecord = asRecord(parent);
|
|
1208
|
+
const key = getRecordKey(parentRecord, parentKeys);
|
|
1209
|
+
if (!parentMap[key]) {
|
|
1210
|
+
parentMap[key] = [];
|
|
1211
|
+
}
|
|
1212
|
+
parentMap[key].push(parentRecord);
|
|
1213
|
+
if (joinExpr.isRelationUnique) {
|
|
1214
|
+
parentRecord[joinExpr.parentField] = null;
|
|
1215
|
+
} else {
|
|
1216
|
+
parentRecord[joinExpr.parentField] = [];
|
|
1217
|
+
}
|
|
1209
1218
|
}
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1219
|
+
for (const childRecord of Array.isArray(childRecords) ? childRecords : [childRecords]) {
|
|
1220
|
+
if (childRecord === null) {
|
|
1221
|
+
continue;
|
|
1222
|
+
}
|
|
1223
|
+
const key = getRecordKey(asRecord(childRecord), childKeys);
|
|
1224
|
+
for (const parentRecord of parentMap[key] ?? []) {
|
|
1225
|
+
if (joinExpr.isRelationUnique) {
|
|
1226
|
+
parentRecord[joinExpr.parentField] = childRecord;
|
|
1227
|
+
} else {
|
|
1228
|
+
parentRecord[joinExpr.parentField].push(childRecord);
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1221
1231
|
}
|
|
1222
1232
|
}
|
|
1223
|
-
return
|
|
1233
|
+
return parentRecords;
|
|
1224
1234
|
}
|
|
1225
1235
|
function paginate(list, { cursor, skip, take }) {
|
|
1226
1236
|
const cursorIndex = cursor !== null ? list.findIndex((item) => doKeysMatch(item, cursor)) : 0;
|
|
@@ -1464,30 +1474,33 @@ var TransactionManager = class {
|
|
|
1464
1474
|
async closeTransaction(tx, status) {
|
|
1465
1475
|
debug("Closing transaction.", { transactionId: tx.id, status });
|
|
1466
1476
|
tx.status = status;
|
|
1467
|
-
|
|
1468
|
-
if (tx.transaction
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1477
|
+
try {
|
|
1478
|
+
if (tx.transaction && status === "committed") {
|
|
1479
|
+
if (tx.transaction.options.usePhantomQuery) {
|
|
1480
|
+
await this.#withQuerySpanAndEvent(PHANTOM_COMMIT_QUERY(), tx.transaction, () => tx.transaction.commit());
|
|
1481
|
+
} else {
|
|
1482
|
+
const query = COMMIT_QUERY();
|
|
1483
|
+
await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query));
|
|
1484
|
+
await tx.transaction.commit();
|
|
1485
|
+
}
|
|
1486
|
+
} else if (tx.transaction) {
|
|
1487
|
+
if (tx.transaction.options.usePhantomQuery) {
|
|
1488
|
+
await this.#withQuerySpanAndEvent(PHANTOM_ROLLBACK_QUERY(), tx.transaction, () => tx.transaction.rollback());
|
|
1489
|
+
} else {
|
|
1490
|
+
const query = ROLLBACK_QUERY();
|
|
1491
|
+
await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query));
|
|
1492
|
+
await tx.transaction.rollback();
|
|
1493
|
+
}
|
|
1474
1494
|
}
|
|
1475
|
-
}
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1495
|
+
} finally {
|
|
1496
|
+
clearTimeout(tx.timer);
|
|
1497
|
+
tx.timer = void 0;
|
|
1498
|
+
this.transactions.delete(tx.id);
|
|
1499
|
+
this.closedTransactions.push(tx);
|
|
1500
|
+
if (this.closedTransactions.length > MAX_CLOSED_TRANSACTIONS) {
|
|
1501
|
+
this.closedTransactions.shift();
|
|
1482
1502
|
}
|
|
1483
1503
|
}
|
|
1484
|
-
clearTimeout(tx.timer);
|
|
1485
|
-
tx.timer = void 0;
|
|
1486
|
-
this.transactions.delete(tx.id);
|
|
1487
|
-
this.closedTransactions.push(tx);
|
|
1488
|
-
if (this.closedTransactions.length > MAX_CLOSED_TRANSACTIONS) {
|
|
1489
|
-
this.closedTransactions.shift();
|
|
1490
|
-
}
|
|
1491
1504
|
}
|
|
1492
1505
|
validateOptions(options) {
|
|
1493
1506
|
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.10",
|
|
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.10",
|
|
35
|
+
"@prisma/driver-adapter-utils": "6.11.0-dev.10"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/jest": "29.5.14",
|