Skip to content

table inheritance 'JOINED' issue with selecting reference fields from base table #5998

@musicthebee

Description

@musicthebee

I have a base task and task which is derived off of basetask using CTI

/*
 * @Entity
 * @InheritanceType("JOINED")
 * @DiscriminatorMap({"base_task" = "BaseTask",
 *     "task" = "Task"`
 * })
 */
class BaseTask 
{
 ...

   /**
     * @var User
     * @ManyToOne(targetEntity="User")
     * @JoinColumn(name="owner_id", referencedColumnName="id", onDelete="SET NULL")
     */
    protected $owner;
 ...//getter and setter
}
class Task extends BaseTask 
{
}

For any query on Task involving owner field using doctrine query builder results in this issue

An exception occurred while executing 'SELECT o0_.id AS id_0 FROM xyz_task w1_ INNER JOIN xyz_base_task w2_ ON w1_.id = w2_.id INNER JOIN xyz_user o0_ ON w1_.owner_id = o0_.id WHERE o0_.id = ? LIMIT 1' with params [2]:

SQLSTATE[42703]: Undefined column: 7 ERROR: column w1_.owner_id does not exist
LINE 1: ...w2_ ON w1_.id = w2_.id INNER JOIN xyz_user o0_ ON w1_.owner_...
^
HINT: Perhaps you meant to reference the column "w2_.owner_id".

Seems like there is an issue with walkjoin in correctly dereferencing the field name to the correct table in the inheritance hierarchy for reference fields only. It works as expected for normal fields.

Any help please?

Doctrine version is 2.5.1 and I tried 2.5.4 as well and its the same behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions