-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[SoftDeleteable] Deleted entities showing up on eager fetches #1463
Comments
it might be that eager fetching does not hit filter, so far I do not know how you could by pass it.. but in the end it is better to handle softdeletion manually. managing softdeleted relations is though task. |
Found someone else with the same problem it seems: http://sofd.developer-works.com/article/21370516/Doctrine+2+filtering+with+EAGER+relations |
How EAGER mapping is handled has changed with doctrine 2.5. It now uses a join instead of two separate queries. The filter does not get added to the join. |
I see, if that is possible, maybe there is a way to hook it in sql filter, if that issue is a concern, you could have a look |
Tried to find a workaround that problem.
in filter listener
added a code to handle configuration param
That would generate query:
The problem is that there is no way to find out what is the alias for template_view table |
I see @Wobbly-Wibbly in general softdeleteable does not fit its concept well with orm, most of the users fallback to managing it manually, same for myself in such cases sadly. Keeping it open since there is no obvious solution so far |
Nowadays, Soft deletes are an anti-pattern but many legacy projects use it. However, it might be worth mentioning this compatibility problem on the SoftDeleteable docs. |
While there are better ways to solve the problems (logging, auditing, archiving) that soft delete is intended to solve. It is an easy option to use when time or resources are not available to implement a better option. Its also very easily understood. Of course it can cause other problems later, depending on the application, so its a tradeoff. |
Softdelete is definitely not an anti-pattern. Some computer science people may think so, but real word use cases, and RAD requires the softdeleteable pattern. I wrote a failing test for this issue: #1550 Unfortunately, It should be fixed by doctrine. |
thanks for the input, will need to mention this in documentation. |
Did somebody create an issue in Doctrine about that problem? |
Using v2.4.7 and Symfony 2.7.7 (also tested on Symfony 2.7.6), if I use
fetch="EAGER"
on one-to-many relations the "deleted" entities appear in the results.E.g.
<one-to-many field="items" target-entity="BasketItem" mapped-by="basket" fetch="EAGER"> <cascade> <cascade-all/> </cascade> </one-to-many>
Is this desired behaviour? Could I be doing something wrong?
The text was updated successfully, but these errors were encountered: