Replies: 1 comment 1 reply
-
Yes. 🙂 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
ORM: 2.20
I’m not sure how to phrase my question and even is this a bug or not, so I’ll just describe the situation.
I have a complex query where I initially used subqueries in JOINs. While refactoring, I decided to split the subquery into multiple JOINs. The final query looks like this:
Since I initially wrote the query as RAW SQL, I expected Doctrine to strictly follow the order in which the JOINs are written. However, that turned out not to be the case.
Doctrine actually executes the query in a different order (simplified example):
As a result, I got an error stating that Doctrine couldn’t resolve alias
b
because it rearranged theJOIN
order.After hours of trial and error, I finally found a solution:
In Doctrine, an alias is not just an alias - it also determines the execution order of JOINs.
So, I had to change my aliases like this:
This effectively creates a dependency chain between aliases and JOINs: fromAlias → Alias.
My question is:
Is this the expected behavior? I couldn't find anything in the documentation (or maybe I missed it) stating that aliases determine the JOIN execution order, overriding the written order of the query.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions