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

Merged
merged 1 commit into from
Jan 20, 2025

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.

@HypeMC
Copy link
Contributor Author

HypeMC commented Jan 20, 2025

@greg0ire @mpdude Sorry to bother you, but could you possibly take a look at this PR? I'm fairly certain this is a bug.

@greg0ire greg0ire added this to the 2.20.2 milestone Jan 20, 2025
@greg0ire greg0ire merged commit 5ad5b11 into doctrine:2.20.x Jan 20, 2025
74 checks passed
@greg0ire
Copy link
Member

Thanks @HypeMC !

@HypeMC HypeMC deleted the fix-reportfieldswheredeclared branch January 21, 2025 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants