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.
@@ -3763,6 +3763,17 @@ var PROJECTION_MUTATION_METHODS = /* @__PURE__ */ new Set([
3763
3763
  "updateManyAndReturn"
3764
3764
  ]);
3765
3765
  var BATCH_CREATE_METHODS = /* @__PURE__ */ new Set(["createMany", "createManyAndReturn"]);
3766
+ function normalizeUniqueWhere(where) {
3767
+ const result = {};
3768
+ for (const [key, value] of Object.entries(where)) {
3769
+ if (key !== "AND" && key !== "OR" && key !== "NOT" && isPlainObject(value) && "equals" in value && Object.keys(value).length === 1) {
3770
+ result[key] = value.equals;
3771
+ } else {
3772
+ result[key] = value;
3773
+ }
3774
+ }
3775
+ return result;
3776
+ }
3766
3777
  function buildDefaultSelectInput(config) {
3767
3778
  const result = {};
3768
3779
  for (const [key, value] of Object.entries(config)) {
@@ -4372,7 +4383,7 @@ function createModelGuardExtension(config) {
4372
4383
  dataSchema,
4373
4384
  method
4374
4385
  );
4375
- const where = isUniqueWhere ? requireWhere(
4386
+ let where = isUniqueWhere ? requireWhere(
4376
4387
  resolved.shape,
4377
4388
  resolved.body.where,
4378
4389
  method,
@@ -4393,6 +4404,7 @@ function createModelGuardExtension(config) {
4393
4404
  }
4394
4405
  if (isUniqueWhere) {
4395
4406
  validateResolvedUniqueWhere(modelName, where, method, uniqueMap);
4407
+ where = normalizeUniqueWhere(where);
4396
4408
  }
4397
4409
  const args = { data, where };
4398
4410
  if (supportsProjection) {
@@ -4431,7 +4443,7 @@ function createModelGuardExtension(config) {
4431
4443
  );
4432
4444
  }
4433
4445
  maybeValidateUniqueWhere(modelName, resolved.shape, method);
4434
- const where = isUniqueWhere ? requireWhere(
4446
+ let where = isUniqueWhere ? requireWhere(
4435
4447
  resolved.shape,
4436
4448
  resolved.body.where,
4437
4449
  method,
@@ -4452,6 +4464,7 @@ function createModelGuardExtension(config) {
4452
4464
  }
4453
4465
  if (isUniqueWhere) {
4454
4466
  validateResolvedUniqueWhere(modelName, where, method, uniqueMap);
4467
+ where = normalizeUniqueWhere(where);
4455
4468
  }
4456
4469
  const args = { where };
4457
4470
  if (supportsProjection) {
@@ -4536,7 +4549,7 @@ function createModelGuardExtension(config) {
4536
4549
  );
4537
4550
  validateResolvedUniqueWhere(modelName, where, "upsert", uniqueMap);
4538
4551
  const args = {
4539
- where,
4552
+ where: normalizeUniqueWhere(where),
4540
4553
  create: createData,
4541
4554
  update: updateData
4542
4555
  };