Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fields of transient classes being considered duplicate with reportFieldsWhereDeclared #11769

Open
wants to merge 1 commit into
base: 2.20.x
Choose a base branch
from

Conversation

HypeMC
Copy link
Contributor

@HypeMC HypeMC commented Dec 18, 2024

When I enabled the reportFieldsWhereDeclared option introduced in #10455, I encountered a problem when using transient classes. For example, the following code produces an error:

abstract class AbstractEntity
{
    #[ORM\Column]
    #[ORM\Id]
    #[ORM\GeneratedValue]
    protected int $id;
}

#[ORM\Entity]
#[ORM\InheritanceType('SINGLE_TABLE')]
#[ORM\DiscriminatorMap(['cat' => Cat::class])]
#[ORM\DiscriminatorColumn(name: 'type')]
abstract class Animal extends AbstractEntity
{
    #[ORM\Column]
    private string $field;
}

#[ORM\Entity]
class Cat extends Animal
{
}
Doctrine\ORM\Mapping\MappingException: Duplicate definition of column 'id' on entity 'Cat' 
in a field or discriminator column mapping.

To my understanding, this shouldn't happen since AbstractEntity is a transient class. Perhaps @mpdude, as the original author, could shed some light on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant