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

Duplicate definition of column for a class with InheritanceType and that extend another class #11404

Open
carross-tlhuillier opened this issue Mar 29, 2024 · 0 comments

Comments

@carross-tlhuillier
Copy link

BC Break Report

Q A
BC Break yes
Version 3.1.1

Summary

If a class has InheritanceType attribute and it extend another class that has at least a property, it generate an error duplicate definication of column the properties in the extended class for orm v3.1.1 and v3.1.0, but worked for v2.7.5.

In MappingException.php line 420:
Duplicate definition of column 'id' on entity 'Entity\CategoryLink' in a field or discriminator column mapping. 

How to reproduce

The MappedSuperclass

namespace MappedSuperClass;

use \Doctrine\ORM\Mapping as ORM;

#[ORM\MappedSuperclass]
abstract class AbstractEntity {

    #[ORM\Column(name: 'id', type: 'integer')]
    #[ORM\Id]
    #[ORM\GeneratedValue]
    protected ?int $id = null;
}

The class with InheritanceType attribute

namespace Entity;

use \Doctrine\ORM\Mapping as ORM;
use \MappedSuperClass\AbstractEntity;

/**
 * @property mixed $Linked
 */
#[ORM\Entity]
#[ORM\Table(name: 'stock_tree')]
#[ORM\InheritanceType('JOINED')]
#[ORM\DiscriminatorColumn(name: 'discriminator', type: 'string')]
#[ORM\DiscriminatorMap([
    'Category' => \Entity\CategoryLink::class
])]
class StockTreeEntity extends AbstractEntity {
}

An inheritor class

namespace Entity;

use \Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
#[ORM\Table(name: 'categories_link')]
class CategoryLink extends StockTreeEntity {

}

Run doctrine orm:schema-tool:update --dump-sql, generate the error

In MappingException.php line 420:
Duplicate definition of column 'id' on entity 'Entity\CategoryLink' in a field or discriminator column mapping.
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

No branches or pull requests

1 participant