Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2717

Join condition results in wrong SQL when used with CTI

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.3
    • Fix Version/s: None
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

      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)

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Philip
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: