DDC-1596: Discriminator column has no table alias #2002

Closed
opened 2026-01-22 13:37:16 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (Jan 11, 2012).

Originally assigned to: @guilhermeblanco on GitHub.

Jira issue originally created by user ghennady:

Some single table inheritance

/****
 * @Orm\Entity
 * @Orm\Table(name="resource")
 * @Orm\InheritanceType("SINGLE_TABLE")
 * @Orm\DiscriminatorColumn(name="type", type="string")
 * @Orm\DiscriminatorMap({"Container" = "Container", "News"="News"})
 */
abstract class Resource
{
}
$em->getRepository('News')->find($id)
/****
* generate SQL like this: 
* SELECT t0.id AS id1, t0.name AS name2, type FROM resource t0 WHERE t0.id = ? AND t0.type IN ('News')
*/

Column type has no table alias.
I expected SQL like this:

SELECT t0.id AS id1, t0.name AS name2, t0.type FROM resource t0 WHERE t0.id = ? AND t0.type IN ('News')

Proposed patch attached

Originally created by @doctrinebot on GitHub (Jan 11, 2012). Originally assigned to: @guilhermeblanco on GitHub. Jira issue originally created by user ghennady: Some single table inheritance ``` /**** * @Orm\Entity * @Orm\Table(name="resource") * @Orm\InheritanceType("SINGLE_TABLE") * @Orm\DiscriminatorColumn(name="type", type="string") * @Orm\DiscriminatorMap({"Container" = "Container", "News"="News"}) */ abstract class Resource { } ``` ``` $em->getRepository('News')->find($id) /**** * generate SQL like this: * SELECT t0.id AS id1, t0.name AS name2, type FROM resource t0 WHERE t0.id = ? AND t0.type IN ('News') */ ``` Column **type** has no table alias. I expected SQL like this: ``` SELECT t0.id AS id1, t0.name AS name2, t0.type FROM resource t0 WHERE t0.id = ? AND t0.type IN ('News') ``` Proposed patch attached
admin added the Bug label 2026-01-22 13:37:16 +01:00
admin closed this issue 2026-01-22 13:37:18 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jan 13, 2012):

Comment created by @guilhermeblanco:

Fixed in bb10211983

@doctrinebot commented on GitHub (Jan 13, 2012): Comment created by @guilhermeblanco: Fixed in https://github.com/doctrine/doctrine2/commit/bb1021198355871bd78b19c7795900be0020520b
Author
Owner

@doctrinebot commented on GitHub (Jan 13, 2012):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Jan 13, 2012): Issue was closed with resolution "Fixed"
Author
Owner

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

Imported 1 attachments from Jira into https://gist.github.com/6ac6d2ee3edb8b8fbe33

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

No dependencies set.

Reference: doctrine/archived-orm#2002