Skip to content

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.

Copy link
Contributor

There hasn't been any activity on this pull request in the past 90 days, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.
If you want to continue working on it, please leave a comment.

@github-actions github-actions bot added the Stale label Jun 30, 2025
@kira0269
Copy link

@derrabus Could you check this PR please ?

@github-actions github-actions bot removed the Stale label Jul 1, 2025
@W0rma
Copy link
Contributor

W0rma commented Aug 13, 2025

As already mentioned in #11031 (comment) I tried this fix in my code base and it worked fine.

Is any help needed in order to get this PR reviewed/merged?

@greg0ire greg0ire added this to the 2.20.7 milestone Aug 26, 2025
@greg0ire greg0ire merged commit 8fe1200 into doctrine:2.20.x Aug 26, 2025
74 checks passed
@mpdude mpdude deleted the fix-many-to-many-in-expression branch September 19, 2025 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants