MappingException with report_fields_where_declared: true #7286

Open
opened 2026-01-22 15:49:10 +01:00 by admin · 0 comments
Owner

Originally created by @BackNot on GitHub (Dec 20, 2023).

Bug Report

Q A
BC Break yes
Version 2.17.1

Summary

With the option report_fields_where_declared I get error

Duplicate definition of column 'id' on entity 'App\Entity\A' in a field or discriminator column mapping.

Reproduce

I updated the doctrine recipe and set this option to true:

report_fields_where_declared: true

I have the following class hierarchy:

[ORM\Table(name: "`classa`")]
#[ORM\Entity(repositoryClass: "App\Repository\ARepository")]
#[ORM\HasLifecycleCallbacks]
class A extends B 
{

   ... 
}

#[ORM\Table(name: "`classb`")]
#[ORM\Entity(repositoryClass: "App\Repository\BRepository")]
#[ORM\HasLifecycleCallbacks]
#[ORM\InheritanceType("JOINED")]
#[ORM\DiscriminatorColumn(name: "dType", type: Types::STRING)]
class B extends C
{
  
    ....
}
abstract class C 
{
     #[Id, ORM\GeneratedValue(strategy: 'AUTO')]
    #[ORM\Column(name: 'id', type: Types::INTEGER)]
    protected ?int $id = null;
}

I understand that with this setting if I have the property "id" both in my parent and child the error will be shown. But currently I just inherit it and I do not overwrite it anywhere.

If I drop class C and put this field in class B this error is not triggered.

Originally created by @BackNot on GitHub (Dec 20, 2023). ### Bug Report | Q | A |------------ | ------ | BC Break | yes | Version | 2.17.1 #### Summary With the option report_fields_where_declared I get error ``` Duplicate definition of column 'id' on entity 'App\Entity\A' in a field or discriminator column mapping. ``` #### Reproduce I updated the doctrine recipe and set this option to true: ``` report_fields_where_declared: true ``` I have the following class hierarchy: ``` [ORM\Table(name: "`classa`")] #[ORM\Entity(repositoryClass: "App\Repository\ARepository")] #[ORM\HasLifecycleCallbacks] class A extends B { ... } ``` ``` #[ORM\Table(name: "`classb`")] #[ORM\Entity(repositoryClass: "App\Repository\BRepository")] #[ORM\HasLifecycleCallbacks] #[ORM\InheritanceType("JOINED")] #[ORM\DiscriminatorColumn(name: "dType", type: Types::STRING)] class B extends C { .... } ``` ``` abstract class C { #[Id, ORM\GeneratedValue(strategy: 'AUTO')] #[ORM\Column(name: 'id', type: Types::INTEGER)] protected ?int $id = null; } ``` I understand that with this setting if I have the property "id" both in my parent and child the error will be shown. But currently I just inherit it and I do not overwrite it anywhere. If I drop class C and put this field in class B this error is not triggered.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7286