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

Closed
opened 2026-01-22 15:49:16 +01:00 by admin · 4 comments
Owner

Originally created by @Arkemlar on GitHub (Dec 22, 2023).

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.

Originally created by @Arkemlar on GitHub (Dec 22, 2023). ### 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 ```php 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:validate`if 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.
admin closed this issue 2026-01-22 15:49:17 +01:00
Author
Owner

@mpdude commented on GitHub (Dec 22, 2023):

So the Entity class is intentionally not marked as an entity, and you know that this is out of supported configuration?

@mpdude commented on GitHub (Dec 22, 2023): So the `Entity` class is intentionally not marked as an entity, and you know that this is out of supported configuration?
Author
Owner

@mpdude commented on GitHub (Dec 22, 2023):

Might be a duplicate of #11129

@mpdude commented on GitHub (Dec 22, 2023): Might be a duplicate of #11129
Author
Owner

@Arkemlar commented on GitHub (Jan 3, 2024):

So the Entity class is intentionally not marked as an entity, and you know that this is out of supported configuration?

Exactly! And I accent that I made this Issue not because it SHOULD work (it shouldn't), but because it is BC break.

@Arkemlar commented on GitHub (Jan 3, 2024): > So the `Entity` class is intentionally not marked as an entity, and you know that this is out of supported configuration? Exactly! And I accent that I made this Issue not because it _SHOULD_ work (it shouldn't), but because it is BC break.
Author
Owner

@mpdude commented on GitHub (Jan 3, 2024):

No, it’s not. It is unsupported, unspecified behavior and as such not subject to any promises given.

@mpdude commented on GitHub (Jan 3, 2024): No, it’s not. It is unsupported, unspecified behavior and as such not subject to any promises given.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7290