mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-2717: Join condition results in wrong SQL when used with CTI #3400
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 @doctrinebot on GitHub (Oct 1, 2013).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user weph:
After upgrading from Doctrine 2.1.7 to 2.3.4 I discovered some unexpected behavior. When joining an entity which uses class table inheritance, the join condition will be put after the last left joined inherited table in the final SQL.
To give a concrete example: The Entity "Product" has multiple features. The "Feature" entity has two child tables "ExampleFeature1" and "ExampleFeature2".
The query builder looks like this:
$this->createQueryBuilder('p')
...
->leftJoin('p.features', 'f', 'WITH', 'f.someCriteria = 1')
...
The final SQL:
Doctrine 2.1.7:
SELECT ...
FROM products p
LEFT JOIN features f ON p.id = f.feature_id AND (f.some_criteria = 1)
LEFT JOIN example_feature1 f1 ON f.id = f1.id
LEFT JOIN example_feature1 f2 ON f.id = f2.id
Doctrine 2.3.4:
SELECT ...
FROM products p
LEFT JOIN features f ON p.id = f.feature_id
LEFT JOIN example_feature1 f1 ON f.id = f1.id
LEFT JOIN example_feature1 f2 ON f.id = f2.id AND (f.some_criteria = 1)