DDC-2717: Join condition results in wrong SQL when used with CTI #3459

Open
doctrinebot opened this Issue Oct 1, 2013 · 0 comments

2 participants

@doctrinebot

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.featureid AND (f.somecriteria = 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 examplefeature1 f2 ON f.id = f2.id AND (f.somecriteria = 1)

@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment