mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 15:02:22 +01:00
Matching criteria on the InverseSide of a ManyToMany relation fails #5000
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @guaycuru on GitHub (Feb 2, 2016).
I'm using DBAL and ORM 2.5.4, with PHP 5.5.15.
I have two classes (Asset and Process) which are linked by a ManyToMany relation as follows:
Now I'm trying to filter Active's Processes by a field (status) as follows:
If I understand correctly, this should work, but instead I'm getting a bunch of exceptions:
And
I've walked through the code and the problem seems to be that on
ManyToManyPersister::loadCriteria()$joinTable is not loading correctly (it's returning an empty string):Which creates this SQL query:
Note how the JOIN table is missing from the query (
JOIN t).Setting JoinTable excplicitly on the Owning side (Process) does not make any difference, but setting it on the Inverse side (Asset) makes the SQL query be built correctly, but those 2 errors still happen:
And
Now, if I understand correctly, setting the JoinTable should not be necessary, and everything should work with no errors... Is this a bug, or did I misunderstand something?
@jaikdean commented on GitHub (Mar 4, 2016):
I'm having exactly the same problem. There are other bugs in the Criteria functionality too (#5687 for example). The more I use it the more I think it's not very well tested or ready for release.
@gnutix commented on GitHub (Apr 27, 2016):
Same issue here.
@AlexeyKosov commented on GitHub (Apr 26, 2017):
More than a year has passed but it's still not fixed, weird
@theofidry commented on GitHub (Apr 26, 2017):
@AlexeyKosov it's still not clear that this is a bug. It's just that the maintainers don't have enough time to investigate every single of them. If you want to make it, create a reproducible scenario and submit a PR.
@seyfer commented on GitHub (May 29, 2017):
Just got the same issue.
Undefined index: relationToSourceKeyColumnsRelation on inversed side
And method with issue
@mikemix commented on GitHub (Jul 10, 2017):
Still not working :(
@jaikdean commented on GitHub (Jul 10, 2017):
@mikemix My advice is to ignore the Criteria feature exists; it has too many huge functionality holes and nothing has been addressed for years. Unless the Doctrine project gets some serious investment I don't foresee this ever being fixed.
@seyfer commented on GitHub (Jul 10, 2017):
I agree with @mikemix here. I'm trying to avoid Criteria and prefer to use Repository methods while developing. But sometimes use of Criteria looks good.
@mikemix commented on GitHub (Jul 10, 2017):
@seyfer well it works well with OneToMany relations, I gave up with ManyToMany though.
@jaikdean commented on GitHub (Jul 10, 2017):
@mikemix It works for OneToMany relations using only equals comparators. "Not equals" being interpreted as "equals" is perhaps a better example than this issue of why I don't touch Criteria anymore.
@mikemix commented on GitHub (Jul 10, 2017):
I would love to contribute however I'm totally out of time, so are the authors I guess. No knowledge about Doctrine's internals does not help as well. There are already 162 pull requests pending! lol. It would be nice if any organization thrown some money to the contributors to help maintain this project. Beside Composer I find Doctrine to be one of the most important libraries out there driving the PHP world.
@permiakov commented on GitHub (Nov 5, 2017):
@jaikdean It's not so good. Equals also has a bug. When you do "count" right before "matching" it's not searching on by non JoinColumn fields(only by parent_id, but not parent_id+name pair for example).
@ricohumme commented on GitHub (Nov 22, 2018):
I am experiencing this issue aswell.
The ManyToManyPersister receive a list of parameters which yields the result if the criteria I'm passing along.
The DefaultQuoteStrategy class then goes looking in the fieldmappings, however the property I'm requesting in my criteria resides within the associations list of the ClassMetadata object.
Can this be addressed please?
@phtmgt commented on GitHub (Jun 27, 2019):
Me too. Can someone give an example of using a repository instead of Criteria for the exact same purpose? Thanks.
@SenseException commented on GitHub (Jun 27, 2019):
It is much appreciated if a PR with a failing test is contributed. PRs with a fix is also welcome.
@mpdude commented on GitHub (Mar 30, 2025):
Could you guys please check if this is still an issue? I believe it has been fixed over the course of the last nine years.
While I was working on #11985 I added test cases for this, and at least for the
eqexpression they seemed to pass even without the changes I made.@1ed commented on GitHub (Aug 7, 2025):
Still exists..