Skip to content

fix: prevent in & not in operators for relationship fields with hasMany: false #12044

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

PatrikKozak
Copy link
Contributor

@PatrikKozak PatrikKozak commented Apr 8, 2025

What?

This PR addresses a bug where relationship fields with hasMany: false (including polymorphic relationships) allowed filtering using the in and not in operators via the Admin UI, which led to query errors.

Why?

MongoDB & Postgres expect an array when using in & not in, but these fields return a single object (not an array).

How?

  • in and not in operators are now excluded from the list of available filter operators for relationship fields where hasMany: false.

Fixes #12014

@tyteen4a03
Copy link
Contributor

I don't think this behavior is correct.

I want to still be able to query many items based on the value of a relationship array (e.g. Item 1 with owner A, item 2 with owner B, item 3 with owner C. I should be able to specify where[owner.value][in]=A ). I think the solution here is instead making sure ins get turned into array of length 1 correctly.

@PatrikKozak
Copy link
Contributor Author

PatrikKozak commented Apr 8, 2025

@tyteen4a03 I see what you're saying and I agree. Noticing there are some discrepancies with using the in operator in general. I'm looking into it.

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.

Querying where[field.value][in] on polymorphic relationships break when only 1 value is specified
2 participants