@prisma/client-engine-runtime 6.10.1-dev.2 → 6.11.0-dev.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/dist/index.js +31 -30
- package/dist/index.mjs +31 -30
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1093,7 +1093,13 @@ var QueryInterpreter = class _QueryInterpreter {
|
|
|
1093
1093
|
childRecords: (await this.interpretNode(joinExpr.child, queryable, scope, generators)).value
|
|
1094
1094
|
}))
|
|
1095
1095
|
);
|
|
1096
|
-
|
|
1096
|
+
if (Array.isArray(parent)) {
|
|
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 };
|
|
1097
1103
|
}
|
|
1098
1104
|
case "transaction": {
|
|
1099
1105
|
if (!this.#transactionManager.enabled) {
|
|
@@ -1235,39 +1241,34 @@ function mapField(value, field) {
|
|
|
1235
1241
|
}
|
|
1236
1242
|
return value;
|
|
1237
1243
|
}
|
|
1238
|
-
function
|
|
1244
|
+
function attachChildrenToParent(parentRecord, children) {
|
|
1239
1245
|
for (const { joinExpr, childRecords } of children) {
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
parentRecord[joinExpr.parentField] = null;
|
|
1252
|
-
} else {
|
|
1253
|
-
parentRecord[joinExpr.parentField] = [];
|
|
1254
|
-
}
|
|
1246
|
+
parentRecord[joinExpr.parentField] = filterChildRecords(childRecords, parentRecord, joinExpr);
|
|
1247
|
+
}
|
|
1248
|
+
return parentRecord;
|
|
1249
|
+
}
|
|
1250
|
+
function filterChildRecords(records, parentRecord, joinExpr) {
|
|
1251
|
+
if (Array.isArray(records)) {
|
|
1252
|
+
const filtered = records.filter((record) => childRecordMatchesParent(asRecord(record), parentRecord, joinExpr));
|
|
1253
|
+
if (joinExpr.isRelationUnique) {
|
|
1254
|
+
return filtered.length > 0 ? filtered[0] : null;
|
|
1255
|
+
} else {
|
|
1256
|
+
return filtered;
|
|
1255
1257
|
}
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
}
|
|
1258
|
+
} else if (records === null) {
|
|
1259
|
+
return null;
|
|
1260
|
+
} else {
|
|
1261
|
+
const record = asRecord(records);
|
|
1262
|
+
return childRecordMatchesParent(record, parentRecord, joinExpr) ? record : null;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
function childRecordMatchesParent(childRecord, parentRecord, joinExpr) {
|
|
1266
|
+
for (const [parentField, childField] of joinExpr.on) {
|
|
1267
|
+
if (parentRecord[parentField] !== childRecord[childField]) {
|
|
1268
|
+
return false;
|
|
1268
1269
|
}
|
|
1269
1270
|
}
|
|
1270
|
-
return
|
|
1271
|
+
return true;
|
|
1271
1272
|
}
|
|
1272
1273
|
function paginate(list, { cursor, skip, take }) {
|
|
1273
1274
|
const cursorIndex = cursor !== null ? list.findIndex((item) => doKeysMatch(item, cursor)) : 0;
|
package/dist/index.mjs
CHANGED
|
@@ -1045,7 +1045,13 @@ var QueryInterpreter = class _QueryInterpreter {
|
|
|
1045
1045
|
childRecords: (await this.interpretNode(joinExpr.child, queryable, scope, generators)).value
|
|
1046
1046
|
}))
|
|
1047
1047
|
);
|
|
1048
|
-
|
|
1048
|
+
if (Array.isArray(parent)) {
|
|
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 };
|
|
1049
1055
|
}
|
|
1050
1056
|
case "transaction": {
|
|
1051
1057
|
if (!this.#transactionManager.enabled) {
|
|
@@ -1187,39 +1193,34 @@ function mapField(value, field) {
|
|
|
1187
1193
|
}
|
|
1188
1194
|
return value;
|
|
1189
1195
|
}
|
|
1190
|
-
function
|
|
1196
|
+
function attachChildrenToParent(parentRecord, children) {
|
|
1191
1197
|
for (const { joinExpr, childRecords } of children) {
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
parentRecord[joinExpr.parentField] = null;
|
|
1204
|
-
} else {
|
|
1205
|
-
parentRecord[joinExpr.parentField] = [];
|
|
1206
|
-
}
|
|
1198
|
+
parentRecord[joinExpr.parentField] = filterChildRecords(childRecords, parentRecord, joinExpr);
|
|
1199
|
+
}
|
|
1200
|
+
return parentRecord;
|
|
1201
|
+
}
|
|
1202
|
+
function filterChildRecords(records, parentRecord, joinExpr) {
|
|
1203
|
+
if (Array.isArray(records)) {
|
|
1204
|
+
const filtered = records.filter((record) => childRecordMatchesParent(asRecord(record), parentRecord, joinExpr));
|
|
1205
|
+
if (joinExpr.isRelationUnique) {
|
|
1206
|
+
return filtered.length > 0 ? filtered[0] : null;
|
|
1207
|
+
} else {
|
|
1208
|
+
return filtered;
|
|
1207
1209
|
}
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
}
|
|
1210
|
+
} else if (records === null) {
|
|
1211
|
+
return null;
|
|
1212
|
+
} else {
|
|
1213
|
+
const record = asRecord(records);
|
|
1214
|
+
return childRecordMatchesParent(record, parentRecord, joinExpr) ? record : null;
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
function childRecordMatchesParent(childRecord, parentRecord, joinExpr) {
|
|
1218
|
+
for (const [parentField, childField] of joinExpr.on) {
|
|
1219
|
+
if (parentRecord[parentField] !== childRecord[childField]) {
|
|
1220
|
+
return false;
|
|
1220
1221
|
}
|
|
1221
1222
|
}
|
|
1222
|
-
return
|
|
1223
|
+
return true;
|
|
1223
1224
|
}
|
|
1224
1225
|
function paginate(list, { cursor, skip, take }) {
|
|
1225
1226
|
const cursorIndex = cursor !== null ? list.findIndex((item) => doKeysMatch(item, cursor)) : 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/client-engine-runtime",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.11.0-dev.1",
|
|
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/
|
|
35
|
-
"@prisma/
|
|
34
|
+
"@prisma/debug": "6.11.0-dev.1",
|
|
35
|
+
"@prisma/driver-adapter-utils": "6.11.0-dev.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/jest": "29.5.14",
|