prisma-guard 1.5.1 → 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.
@@ -735,24 +735,24 @@ function mergeUniqueWhereForced(where, forced) {
735
735
  }
736
736
  function applyBuiltShape(built, body, isUniqueMethod) {
737
737
  let parseable = body;
738
+ const hasWhereInSchema = "where" in built.zodSchema.shape;
738
739
  if (isPlainObject(body)) {
739
740
  const bodyObj = body;
740
- if (isPlainObject(bodyObj.where)) {
741
- const where = { ...bodyObj.where };
742
- let modified = false;
743
- if (built.forcedOnlyWhereKeys.size > 0) {
744
- for (const key of built.forcedOnlyWhereKeys) {
745
- if (key in where) {
746
- delete where[key];
747
- modified = true;
748
- }
749
- }
750
- }
751
- if (Object.keys(where).length === 0 && hasWhereForced(built.forcedWhere)) {
741
+ if ("where" in bodyObj) {
742
+ if (!hasWhereInSchema) {
752
743
  const { where: _, ...rest } = bodyObj;
753
744
  parseable = rest;
754
- } else if (modified) {
755
- parseable = { ...bodyObj, where };
745
+ } else if (built.forcedOnlyWhereKeys.size > 0 && isPlainObject(bodyObj.where)) {
746
+ const where = { ...bodyObj.where };
747
+ for (const key of built.forcedOnlyWhereKeys) {
748
+ delete where[key];
749
+ }
750
+ if (Object.keys(where).length === 0 && hasWhereForced(built.forcedWhere)) {
751
+ const { where: _, ...rest } = bodyObj;
752
+ parseable = rest;
753
+ } else {
754
+ parseable = { ...bodyObj, where };
755
+ }
756
756
  }
757
757
  }
758
758
  }