DDC-707: Discriminator column cannot be used in the query builder #872

Open
opened 2026-01-22 12:53:20 +01:00 by admin · 0 comments
Owner

Originally created by @doctrinebot on GitHub (Jul 21, 2010).

Jira issue originally created by user gedrox:

When having entities

/****
 * @Entity
 * @InheritanceType("SINGLE_TABLE")
 * @DiscriminatorColumn(name="discr", type="string")
 * @DiscriminatorMap({"b" = "B", "c" = "C"})
 */
class A {
    /*** @Id @Column(type="integer") @GeneratedValue **/
    protected $id;
}
/*** @Entity **/
class B extends A {}
/*** @Entity **/
class C extends A {}

The DQL "SELECT a FROM A a ORDER BY a.discr" cannot be run because of error "Class A has no field or association named discr".

This would be very useful when having to read both - B and C data using one query, but in particular order.

Originally created by @doctrinebot on GitHub (Jul 21, 2010). Jira issue originally created by user gedrox: When having entities ``` /**** * @Entity * @InheritanceType("SINGLE_TABLE") * @DiscriminatorColumn(name="discr", type="string") * @DiscriminatorMap({"b" = "B", "c" = "C"}) */ class A { /*** @Id @Column(type="integer") @GeneratedValue **/ protected $id; } /*** @Entity **/ class B extends A {} /*** @Entity **/ class C extends A {} ``` The DQL "SELECT a FROM A a ORDER BY a.discr" cannot be run because of error "Class A has no field or association named discr". This would be very useful when having to read both - B and C data using one query, but in particular order.
admin added the Improvement label 2026-01-22 12:53:20 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#872