DDC-331: Select Field of Root on Child Dql Alias generates wrong SQL #407

Closed
opened 2026-01-22 12:37:22 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Feb 14, 2010).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user @beberlei:

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.

Originally created by @doctrinebot on GitHub (Feb 14, 2010). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user @beberlei: 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.
admin added the Bug label 2026-01-22 12:37:22 +01:00
admin closed this issue 2026-01-22 12:37:23 +01:00
Author
Owner

@doctrinebot commented on GitHub (Feb 14, 2010):

Comment created by @beberlei:

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
@doctrinebot commented on GitHub (Feb 14, 2010): Comment created by @beberlei: 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 ```
Author
Owner

@doctrinebot commented on GitHub (Mar 2, 2010):

Comment created by @guilhermeblanco:

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.

@doctrinebot commented on GitHub (Mar 2, 2010): Comment created by @guilhermeblanco: Added [DDC-331](http://www.doctrine-project.org/jira/browse/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.
Author
Owner

@doctrinebot commented on GitHub (Mar 2, 2010):

Issue was closed with resolution "Cannot Reproduce"

@doctrinebot commented on GitHub (Mar 2, 2010): Issue was closed with resolution "Cannot Reproduce"
Author
Owner

@doctrinebot commented on GitHub (Dec 13, 2015):

Imported 1 attachments from Jira into https://gist.github.com/881dd1939fd47b9d32c4

@doctrinebot commented on GitHub (Dec 13, 2015): Imported 1 attachments from Jira into https://gist.github.com/881dd1939fd47b9d32c4 - [10367_DDCx001Test.php](https://gist.github.com/881dd1939fd47b9d32c4#file-10367_DDCx001Test-php)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#407