prisma-guard 1.17.0 → 1.18.0

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.
@@ -3794,6 +3794,17 @@ var PROJECTION_MUTATION_METHODS = /* @__PURE__ */ new Set([
3794
3794
  "updateManyAndReturn"
3795
3795
  ]);
3796
3796
  var BATCH_CREATE_METHODS = /* @__PURE__ */ new Set(["createMany", "createManyAndReturn"]);
3797
+ function normalizeUniqueWhere(where) {
3798
+ const result = {};
3799
+ for (const [key, value] of Object.entries(where)) {
3800
+ if (key !== "AND" && key !== "OR" && key !== "NOT" && isPlainObject(value) && "equals" in value && Object.keys(value).length === 1) {
3801
+ result[key] = value.equals;
3802
+ } else {
3803
+ result[key] = value;
3804
+ }
3805
+ }
3806
+ return result;
3807
+ }
3797
3808
  function buildDefaultSelectInput(config) {
3798
3809
  const result = {};
3799
3810
  for (const [key, value] of Object.entries(config)) {
@@ -4403,7 +4414,7 @@ function createModelGuardExtension(config) {
4403
4414
  dataSchema,
4404
4415
  method
4405
4416
  );
4406
- const where = isUniqueWhere ? requireWhere(
4417
+ let where = isUniqueWhere ? requireWhere(
4407
4418
  resolved.shape,
4408
4419
  resolved.body.where,
4409
4420
  method,
@@ -4424,6 +4435,7 @@ function createModelGuardExtension(config) {
4424
4435
  }
4425
4436
  if (isUniqueWhere) {
4426
4437
  validateResolvedUniqueWhere(modelName, where, method, uniqueMap);
4438
+ where = normalizeUniqueWhere(where);
4427
4439
  }
4428
4440
  const args = { data, where };
4429
4441
  if (supportsProjection) {
@@ -4462,7 +4474,7 @@ function createModelGuardExtension(config) {
4462
4474
  );
4463
4475
  }
4464
4476
  maybeValidateUniqueWhere(modelName, resolved.shape, method);
4465
- const where = isUniqueWhere ? requireWhere(
4477
+ let where = isUniqueWhere ? requireWhere(
4466
4478
  resolved.shape,
4467
4479
  resolved.body.where,
4468
4480
  method,
@@ -4483,6 +4495,7 @@ function createModelGuardExtension(config) {
4483
4495
  }
4484
4496
  if (isUniqueWhere) {
4485
4497
  validateResolvedUniqueWhere(modelName, where, method, uniqueMap);
4498
+ where = normalizeUniqueWhere(where);
4486
4499
  }
4487
4500
  const args = { where };
4488
4501
  if (supportsProjection) {
@@ -4567,7 +4580,7 @@ function createModelGuardExtension(config) {
4567
4580
  );
4568
4581
  validateResolvedUniqueWhere(modelName, where, "upsert", uniqueMap);
4569
4582
  const args = {
4570
- where,
4583
+ where: normalizeUniqueWhere(where),
4571
4584
  create: createData,
4572
4585
  update: updateData
4573
4586
  };