Skip to content

Duplicate definition of column 'id' on entity '<FQCN>' in a field or discriminator column mapping. #11136

@Arkemlar

Description

@Arkemlar

BC Break Report

Q A
BC Break yes
Version 2.16.*

Summary

I use inheritance mapping and since v2.16 it is no longer working. Exact scheme example in the bottom.

Previous behavior

Worked fine.

Current behavior

In a newer version I got following error:
Duplicate definition of column 'id' on entity 'App\Context\Task\Model\TaskHistory' in a field or discriminator column mapping.

How to reproduce

abstract class Entity
{
    #[
        ORM\Id,
        ORM\GeneratedValue,
        ORM\Column(type: 'bigint', nullable: false, options: ['unsigned' => true])
    ]
    protected int $id;
}

#[
    ORM\Entity,
    ORM\InheritanceType('JOINED'),
    ORM\DiscriminatorMap([
        'task' => TaskHistory::class,
    ])
]
abstract class History extends Entity
{}


#[ORM\Entity]
class TaskHistory extends History
{}

Then bin/console doctrine:schema:validateif you use symfony.

If I move id field to History class, then it works as expected. Also works if I use trait for Id instead of abstract class.

I know that doctrine not guarantees plain old OOP classes inheritance to work but since it is BC break I decided to report it because it might indicate a new mapping bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions