Skip to content
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

Fix IN/NOT IN expression handling and support enums when matching on to-many-collections #11895

Open
wants to merge 1 commit into
base: 2.20.x
Choose a base branch
from

Conversation

mpdude
Copy link
Contributor

@mpdude mpdude commented Mar 28, 2025

This fixes that using a Criteria with an IN or NIN expression on a many-to-many collection currently leads to an SQL error (#6173). The ManyToMany persister needs to know about the slightly different SQL syntax for [NOT] IN ().

In the case of [NOT] IN expressions, the value will be an array, which also required me to change (fix?) the parameter type handling. I have pulled the necessary code from the BasicEntityPersister and placed it as static helper methods in PersisterHelper.

This is somewhat inspired by #11516, which aims at fixing #11481: By re-using the parameter type handling code, it also fixes using backed enums in EQ, IN and NIN expressions within Criteria when matching() on one-to-many and many-to-many collections.

Fixes #6173, fixes #11031, fixes #11481, closes #11516.

@mpdude mpdude force-pushed the fix-many-to-many-in-expression branch from 5f4137b to cf240eb Compare March 30, 2025 20:38
@mpdude mpdude changed the title Fix IN/NOT IN criteria/expression handling for to-many-Connections Fix IN/NOT IN expression handling and support enums when matching on to-many-collections Mar 30, 2025
@mpdude mpdude changed the title Fix IN/NOT IN expression handling and support enums when matching on to-many-collections Fix IN/NOT IN expression handling, support enums when matching on to-many-collections Mar 30, 2025
@mpdude mpdude changed the title Fix IN/NOT IN expression handling, support enums when matching on to-many-collections Fix IN/NOT IN expression handling and support enums when matching on to-many-collections Mar 30, 2025
… on to-many-collections

This fixes that using a `Criteria` with an `IN` or `NIN` expression on a to-many collection currently leads to an SQL error (doctrine#6173). The `ManyToMany` persister needs to know about the slightly different SQL syntax for `[NOT] IN ()`.

In the case of `[NOT] IN` expressions, the value will be an array, which also required me to change (I guess "fix") the parameter type handling. I have pulled the necessary code from the `BasicEntityPersister` and placed it as static helper methods in `PersisterHelper`.

This is somewhat inspired by doctrine#11516, which aims at fixing doctrine#11481: By re-using the parameter type handling code, it also fixes using backed enums in `EQ`, `IN` and `NIN` expressions within `Criteria` when `matching()` on one-to-many and many-to-many collections.
Copy link

@kira0269 kira0269 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. More complete than mine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants