Skip to content

fix(db-mongodb): ensures same level operators are respected - #11087

Merged
JarrodMFlesch merged 2 commits into
mainfrom
fix/db-mongodb/respect-all-field-operators
Feb 10, 2025
Merged

JarrodMFlesch merged 2 commits into
mainfrom
fix/db-mongodb/respect-all-field-operators

Conversation

@JarrodMFlesch

@JarrodMFlesch JarrodMFlesch commented Feb 10, 2025 •

Copy link
Copy Markdown
Contributor

What?

If you had multiple operator constraints on a single field, the last one defined would be the only one used.

Example:

where: {
  id: {
    in: [doc2.id],
    not_in: [], // <-- only respected this operator constraint
  },
}

and

where: {
  id: {
    not_in: [],
    in: [doc2.id], // <-- only respected this operator constraint
  },
}

They would yield different results.

Why?

The results were not merged into an $and query inside parseParams.

How?

Merges the results within an $and constraint.

Fixes #10944

Supersedes #11011

@JarrodMFlesch
JarrodMFlesch merged commit d2fe9b0 into main Feb 10, 2025
@JarrodMFlesch
JarrodMFlesch deleted the fix/db-mongodb/respect-all-field-operators branch February 10, 2025 21:29
@github-actions

Copy link
Copy Markdown
Contributor

🚀 This is included in version v3.23.0

kendelljoseph pushed a commit that referenced this pull request Feb 21, 2025
### What?
If you had multiple operator constraints on a single field, the last one
defined would be the only one used.

Example:
```ts
where: {
  id: {
    in: [doc2.id],
    not_in: [], // <-- only respected this operator constraint
  },
}
```

and
```ts
where: {
  id: {
    not_in: [],
    in: [doc2.id], // <-- only respected this operator constraint
  },
}
```

They would yield different results.

### Why?
The results were not merged into an `$and` query inside parseParams.

### How?
Merges the results within an `$and` constraint.

Fixes #10944

Supersedes #11011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot filter on id field via filterOptions callback

1 participant