prisma-guard 1.17.0 → 1.18.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/runtime/index.cjs
CHANGED
|
@@ -1118,6 +1118,10 @@ function collectEqualityFields(where, model, typeMap) {
|
|
|
1118
1118
|
continue;
|
|
1119
1119
|
if (typeMap && model && typeMap[model]?.[key]?.isRelation)
|
|
1120
1120
|
continue;
|
|
1121
|
+
if (value !== null && value !== void 0 && !isPlainObject(value) && !Array.isArray(value)) {
|
|
1122
|
+
fields.add(key);
|
|
1123
|
+
continue;
|
|
1124
|
+
}
|
|
1121
1125
|
if (!value || !isPlainObject(value))
|
|
1122
1126
|
continue;
|
|
1123
1127
|
if (Object.keys(value).every((op) => op === "equals")) {
|
|
@@ -3794,6 +3798,17 @@ var PROJECTION_MUTATION_METHODS = /* @__PURE__ */ new Set([
|
|
|
3794
3798
|
"updateManyAndReturn"
|
|
3795
3799
|
]);
|
|
3796
3800
|
var BATCH_CREATE_METHODS = /* @__PURE__ */ new Set(["createMany", "createManyAndReturn"]);
|
|
3801
|
+
function normalizeUniqueWhere(where) {
|
|
3802
|
+
const result = {};
|
|
3803
|
+
for (const [key, value] of Object.entries(where)) {
|
|
3804
|
+
if (key !== "AND" && key !== "OR" && key !== "NOT" && isPlainObject(value) && "equals" in value && Object.keys(value).length === 1) {
|
|
3805
|
+
result[key] = value.equals;
|
|
3806
|
+
} else {
|
|
3807
|
+
result[key] = value;
|
|
3808
|
+
}
|
|
3809
|
+
}
|
|
3810
|
+
return result;
|
|
3811
|
+
}
|
|
3797
3812
|
function buildDefaultSelectInput(config) {
|
|
3798
3813
|
const result = {};
|
|
3799
3814
|
for (const [key, value] of Object.entries(config)) {
|
|
@@ -4403,7 +4418,7 @@ function createModelGuardExtension(config) {
|
|
|
4403
4418
|
dataSchema,
|
|
4404
4419
|
method
|
|
4405
4420
|
);
|
|
4406
|
-
|
|
4421
|
+
let where = isUniqueWhere ? requireWhere(
|
|
4407
4422
|
resolved.shape,
|
|
4408
4423
|
resolved.body.where,
|
|
4409
4424
|
method,
|
|
@@ -4424,6 +4439,7 @@ function createModelGuardExtension(config) {
|
|
|
4424
4439
|
}
|
|
4425
4440
|
if (isUniqueWhere) {
|
|
4426
4441
|
validateResolvedUniqueWhere(modelName, where, method, uniqueMap);
|
|
4442
|
+
where = normalizeUniqueWhere(where);
|
|
4427
4443
|
}
|
|
4428
4444
|
const args = { data, where };
|
|
4429
4445
|
if (supportsProjection) {
|
|
@@ -4462,7 +4478,7 @@ function createModelGuardExtension(config) {
|
|
|
4462
4478
|
);
|
|
4463
4479
|
}
|
|
4464
4480
|
maybeValidateUniqueWhere(modelName, resolved.shape, method);
|
|
4465
|
-
|
|
4481
|
+
let where = isUniqueWhere ? requireWhere(
|
|
4466
4482
|
resolved.shape,
|
|
4467
4483
|
resolved.body.where,
|
|
4468
4484
|
method,
|
|
@@ -4483,6 +4499,7 @@ function createModelGuardExtension(config) {
|
|
|
4483
4499
|
}
|
|
4484
4500
|
if (isUniqueWhere) {
|
|
4485
4501
|
validateResolvedUniqueWhere(modelName, where, method, uniqueMap);
|
|
4502
|
+
where = normalizeUniqueWhere(where);
|
|
4486
4503
|
}
|
|
4487
4504
|
const args = { where };
|
|
4488
4505
|
if (supportsProjection) {
|
|
@@ -4567,7 +4584,7 @@ function createModelGuardExtension(config) {
|
|
|
4567
4584
|
);
|
|
4568
4585
|
validateResolvedUniqueWhere(modelName, where, "upsert", uniqueMap);
|
|
4569
4586
|
const args = {
|
|
4570
|
-
where,
|
|
4587
|
+
where: normalizeUniqueWhere(where),
|
|
4571
4588
|
create: createData,
|
|
4572
4589
|
update: updateData
|
|
4573
4590
|
};
|