mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Filter on JOIN #5465
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 @yp28 on GitHub (Mar 15, 2017).
Hi, I'm having a problem filtering entities when retrieved through a join.
This is my case (simplified):
Let's say I have a User entity, and a Car entity. Both entities are soft-deletable (whether they're a good pattern or bad, I use them). When I
finda User, the filter is applied, as well as with the Car entity. However, when Ifinda User and include the Car in a join, the filter is only applied to the User entity, and it returns the deleted Car entities as well.I could not find any documentation as to whether this is expected (and wanted) behaviour, or a "bug". Shouldn't the filters also be applied to fetched relations?
Can anyone elaborate?
Edit: upon better search, this might be related to #6037
@szymach commented on GitHub (Apr 18, 2017):
From the docs:
So this would seem like a bug. Did you try running the query with XDebug?
As for the PR you linked - do you have eager fetch as well?
@yp28 commented on GitHub (Apr 19, 2017):
@szymach, we do have eager fetch configured for both entities that were involved.
I did not run it with XDebug enabled, we just reversed the queried the related entity as it was more important than the one we were query-ing.
@mssimi commented on GitHub (Apr 29, 2017):
I can confirm combining fetch="EAGER" and SQLFilter does not work well. SQLFilter is not aplied in this scenario.
Fix would be nice:D
@lcobucci commented on GitHub (Apr 29, 2017):
@mssimi we're doing the best we can with the contributors that we have but since the failing test to reproduce it is available anyone could send a patch to fix the issue 😉
@lukaszjakubek commented on GitHub (Jun 30, 2017):
I confirm this on one-to-one bidirectional association. After owning side is soft deleted. When i get inversed side entity by simple select it also join owning side without filter applied.
Example:
This class has also SoftDeleteable extension applied from Atlantic18/DoctrineExtensions which adds SQL filters.
And when i try to select single entity i get SQL:
You can see:
LEFT JOIN app_document t16 ON ...withoutAND (t0.deleted_at IS NULL)but WHERE has valid filter on t0 in the same time.@lcobucci commented on GitHub (Aug 6, 2017):
@lukaszjakubek could you please send us a failing test case that reproduces that behaviour? It would help us a lot to identify and fix the issue you're describing.
You can find examples on
388afb46d0/tests/Doctrine/Tests/ORM/Functional/Ticket@seyfer commented on GitHub (Oct 19, 2017):
Here is connected issue in Atlantic18/DoctrineExtensions with explanation
https://github.com/Atlantic18/DoctrineExtensions/issues/1463
and failing test case
https://github.com/Atlantic18/DoctrineExtensions/pull/1550
@fuser82 commented on GitHub (Nov 30, 2019):
Any news from this?
@fleckiboy commented on GitHub (Aug 25, 2020):
Are there any news on this issue? I'm facing exactly the same problem after upgrading from v2.4.8 to v2.5.14.
SQL-Filter seems to be ignored for Eager Fetch Joins of Relations.
Is this Bug fixed in newer versions or is it still remaining in the follow up versions of Doctrine?
@pana1990 commented on GitHub (Oct 2, 2020):
The same issue :(
@GaylordP commented on GitHub (Aug 18, 2021):
Same problem in 2021 :(
@Miras4207 commented on GitHub (Jan 18, 2023):
We are also experiencing this issue and wish it could be resolved.
@eigan commented on GitHub (Jan 18, 2023):
This issue is labeled as missing-tests, but here is a relevant testcase: https://github.com/doctrine/orm/pull/6037
Edit: This PR is actually mentioned in OP.
@ahmed-bhs commented on GitHub (May 11, 2023):
Same problem in 2023 :(
@jeandanyel commented on GitHub (Sep 15, 2023):
Same problem here 🙁
@esserj commented on GitHub (Feb 7, 2025):
Recent PR #11707 merge could fix it in 2.20.3
Can any of you confirm that these cases are working now? so we can get this issue resolved.