prisma-guard 1.6.0 → 1.6.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.
@@ -705,28 +705,25 @@ function mergeUniqueWhereForced(where, forced) {
705
705
  }
706
706
  function applyBuiltShape(built, body, isUniqueMethod) {
707
707
  let parseable = body;
708
+ const hasWhereInSchema = "where" in built.zodSchema.shape;
708
709
  if (isPlainObject(body)) {
709
710
  const bodyObj = body;
710
- if (isPlainObject(bodyObj.where)) {
711
- const where = { ...bodyObj.where };
712
- let modified = false;
713
- if (built.forcedOnlyWhereKeys.size > 0) {
714
- for (const key of built.forcedOnlyWhereKeys) {
715
- if (key in where) {
716
- delete where[key];
717
- modified = true;
718
- }
719
- }
720
- }
721
- if (Object.keys(where).length === 0 && hasWhereForced(built.forcedWhere)) {
711
+ if ("where" in bodyObj) {
712
+ if (!hasWhereInSchema) {
722
713
  const { where: _, ...rest } = bodyObj;
723
714
  parseable = rest;
724
- } else if (modified) {
725
- parseable = { ...bodyObj, where };
715
+ } else if (built.forcedOnlyWhereKeys.size > 0 && isPlainObject(bodyObj.where)) {
716
+ const where = { ...bodyObj.where };
717
+ for (const key of built.forcedOnlyWhereKeys) {
718
+ delete where[key];
719
+ }
720
+ if (Object.keys(where).length === 0 && hasWhereForced(built.forcedWhere)) {
721
+ const { where: _, ...rest } = bodyObj;
722
+ parseable = rest;
723
+ } else {
724
+ parseable = { ...bodyObj, where };
725
+ }
726
726
  }
727
- } else if ("where" in bodyObj && hasWhereForced(built.forcedWhere) && !built.zodSchema.shape.where) {
728
- const { where: _, ...rest } = bodyObj;
729
- parseable = rest;
730
727
  }
731
728
  }
732
729
  const validated = built.zodSchema.parse(parseable);