Fix logic of protection against adding same join multiple times#3308
Fix logic of protection against adding same join multiple times#3308klamparski wants to merge 1 commit intoapi-platform:mainfrom
Conversation
Before that commit `QueryBuilderHelper::addJoinOnce` did not allow to add multiple joins for same association even if new join should have different type than already existing. That means that extensions and filters may affects each other depending on the apply order. Moreover this commit removes forcing left join if in query already exists at least one left join before. That behaviour also could affect filters depending of apply order.
|
I see now that my changes make test Is that really expected that if any LEFT JOIN in query exists then all next joins from filters will be also LEFT? What is the reason for that? |
Because this usually comes from the fact that the relation is nullable. If you're adding an |
I think that's correct. Doing an |
|
It seems this fix is not relevant. I'm closing this PR. |
Hello,
In project which I'm involved we found problems with filtering. Our custom full text filter is filtering by nested properties of associations thus it is trying to add LEFT JOIN.
It works correctly but not in all cases. If before our full text filter any other filter (or extension) is applied and it adds INNER JOIN for association, then our LEFT JOIN is ignored because
QueryBuilderHelper::getExistingJoindoes not take into account the type of the JOIN and simply returns true if join for this association already exists.Such behaviour makes filters not reliable, because they can give different results depending on apply ordering.
Moreover in
QueryBuilderHelper::addJoinOncethere was also condition which makes all joins type LEFT if there exist already any LEFT join in the query. It also makes filters not reliable. This PR also removes that condition.