Details
-
Type:
Bug
-
Status:
Reopened
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 2.3
-
Fix Version/s: None
-
Component/s: ORM
-
Security Level: All
-
Labels:None
Description
The condition on the discriminator column is placed in the WHERE clause when using arbitrary join syntax, which renders LEFT JOINs useless.
Given these classes:
A - no inheritance
B1 - abstract, root of a hierarchy, discriminator column is named 'type'
I setup a query builder like this:
$qb->select('a.id AS idA, b.id AS idB')
->from('\Entity\A', 'a')
->leftJoin('\Entity\B1', 'b', \Doctrine\ORM\Query\Expr\Join::WITH, 'a.something=b.something');
And the SQL Doctrine generates is something like this:
SELECT a.id, b.id FROM a LEFT JOIN b ON (a.something=b.something) WHERE b.type IN ('1', '2', '3')
The problems is that the WHERE condition makes the left join useless.
The condition on the discriminator column should be placed in the JOIN clause to avoid the problem.
Issue Links
- duplicates
-
DDC-1940
Doctrine DQL: erroneous sql generation from dql join with "WITH" or "WHERE" clause
-
Can this be somehow worked around? If not, it is really serious problem...