mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Duplicate definition of column amount for Money embedded objects #5604
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 @mahbubkabir on GitHub (Jul 10, 2017).
Originally assigned to: @Ocramius on GitHub.
I've got a model with multiple Money properties; everything in the model shares a common currency (for example's sake, let's assume an Order model with amount and tax Money properties)
I'm using moneyphp/money to store money information and doctrine embeddables to store them. Mapping as below
And money embeddable as below
This db table already exists on production and cannot be changed. This money lib has two properties amount and currency. So when Doctrine tries to hydrate the embedded objects it complains about duplicate …
Duplicate definition of column 'amount' on entity in a field or discriminator column mapping..I understand, doctrine is stopping us from redeclaring the same property but Money lib/object will always have the same property(i.e. amount and currency). Is there any way to tell doctrine to reuse the same field name without using prefix?
@Ocramius commented on GitHub (Jul 12, 2017):
use-column-prefix="false" />How is this supposed to work if both imports have no prefix? Of course the columns will collide...
No, as this breaks the 1:1 mapping between entities and table definitions. I've seen this break in very unexpected ways in the past too.
You can just duplicate the column