mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-4157: ManyToMany matching criteria set wrong expressions #4917
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 @doctrinebot on GitHub (Dec 3, 2015).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user eliotik:
I have two entities: User and Event, they are in ManyToMany relationship.
I try to match events by criteria from $user->getEvents() but get nothing. After checking profiler i saw that criteria did not work correctly while build sql, i used expression lte and gte but in sql doctrine continue to use =.
Here are my classes.
User:
Event:
And here is how i try to find events related to user:
In profiler/debug i see next sql:
And with applied parameters:
I changed WHERE to next:
And with that sql i got correct result.
When i use same criteria right with repository without relation to user - everything is ok:
This is formatted sql:
And with applied parameters:
As you can see, for case when i dont try to search through relation - everything is ok, i get result. But when i try related events to user with use of Criteria - it fails and return empty result cause of incorrect sql.
I use php 5.6.*, symfony 2.8, doctrine 2.5.2, latest MySQL.
Any help will be very appreciated.
Thank you.
@DonCallisto commented on GitHub (Feb 12, 2016):
@beberlei I suppose that this http://stackoverflow.com/questions/35358597/in-predicate-with-criteria-filtering-isnt-working/35365985#35365985 is related with this bug. Don't know if it adds some details for resolution. If not, sorry for this post :)