mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Entity extending embeddable: Duplicate definition of column 'colName' on entity 'Foo' in a field or discriminator column mapping. #6435
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @marhub on GitHub (Mar 25, 2020).
Originally assigned to: @malarzm on GitHub.
BC Break Report
Summary
code below stopped working after update from 2.7.0 to 2.7.2.
Downgrading fixes issue.
/** * @ORM\Embeddable() */ class Money { /** * @ORM\Column(type = "integer") */ protected $value = 0; } /** * @ORM\Entity */ class Price extends Money { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ private $priceId; }Previous behavior
That code was working in 2.7.0
Current behavior
Schema validation fails with
@SenseException commented on GitHub (Mar 26, 2020):
Why do you extend the embeddable class in your example?
@malarzm commented on GitHub (May 7, 2020):
@marhub I'm sorry to say, but an Entity extending Embeddable is not correct mapping. We will improve the schema validation to let users know about it. I believe the correct approach in your case is
Pricehaving aMoneyfield:The other (and less feasible in my opinion) approach would be to have
Moneymapped as a@ORM\MappedSuperclassand have two separate classes:MoneyEmbedded extends MoneyandPrice extends Money- that mapping would be correct from ORM's point of view.@marhub commented on GitHub (May 26, 2020):
OK, but there is no information about Embeds not extending Entities in documentation, is it ?
So seems like this "bug fix" will be BC break for many people like me. For now we have to stick to doctrine 2.7.0 :(
@beberlei commented on GitHub (May 26, 2020):
@marhub we have reverted the commits in 2.7.1 and 2.7.2 related to embeddables, however we will start throwing Schema Validator errors for this use-case and remove it in the future. So you can prepare yourself to fix the mapping. Entities cannot extend Embeddables. Instead you can have a MappedSuperclass and extend it from both the Entity and the Embeddable.