Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-331

Select Field of Root on Child Dql Alias generates wrong SQL

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 2.0-ALPHA4
    • Fix Version/s: 2.0-BETA2
    • Component/s: DQL
    • Security Level: All
    • Labels:
      None

      Description

      In a Class Table Inheritance Scenario, when you select a field "c.name" on a dql alias c of a child entity, where the field is really "p.name" on the parent the DQL parser does not recognize this and does not change the sql table alias. Test-Case attached.

        Activity

        Hide
        Benjamin Eberlei added a comment -

        DQL is:

        SELECT e.name FROM Doctrine\Tests\Models\Company\CompanyEmployee e
        

        SQL is:

        SELECT c0_.name AS name0, c1_.discr AS discr1 FROM company_employees c0_ INNER JOIN company_persons c1_ ON c0_.id = c1_.id LEFT JOIN company_managers c2_ ON c0_.id = c2_.id
        

        But should be:

        SELECT *c1_*.name AS name0, c1_.discr AS discr1 FROM company_employees c0_ INNER JOIN company_persons c1_ ON c0_.id = c1_.id LEFT JOIN company_managers c2_ ON c0_.id = c2_.id
        
        Show
        Benjamin Eberlei added a comment - DQL is: SELECT e.name FROM Doctrine\Tests\Models\Company\CompanyEmployee e SQL is: SELECT c0_.name AS name0, c1_.discr AS discr1 FROM company_employees c0_ INNER JOIN company_persons c1_ ON c0_.id = c1_.id LEFT JOIN company_managers c2_ ON c0_.id = c2_.id But should be: SELECT *c1_*.name AS name0, c1_.discr AS discr1 FROM company_employees c0_ INNER JOIN company_persons c1_ ON c0_.id = c1_.id LEFT JOIN company_managers c2_ ON c0_.id = c2_.id
        Hide
        Guilherme Blanco added a comment -

        Added DDC-331 to core and provided test case is no longer valid.
        Closing this ticket and committing the test case to prevent a possible BC break in the future.

        Show
        Guilherme Blanco added a comment - Added DDC-331 to core and provided test case is no longer valid. Closing this ticket and committing the test case to prevent a possible BC break in the future.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: