Duplicate definition of column amount for Money embedded objects #5603

Open
opened 2026-01-22 15:12:28 +01:00 by admin · 0 comments
Owner

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

    <embedded name="amount" class="Money\Money" use-column-prefix="false" />
    <embedded name="tax" class="Money\Money" use-column-prefix="false" />

And money embeddable as below

<embeddable name="Money\Money">
    <field name="amount" type="integer" nullable="true" column="amount" />
    <embedded name="currency" class="Money\Currency" use-column-prefix="false" />
</embeddable>

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?

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 <embedded name="amount" class="Money\Money" use-column-prefix="false" /> <embedded name="tax" class="Money\Money" use-column-prefix="false" /> And money embeddable as below <embeddable name="Money\Money"> <field name="amount" type="integer" nullable="true" column="amount" /> <embedded name="currency" class="Money\Currency" use-column-prefix="false" /> </embeddable> 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?
admin added the InvalidQuestion labels 2026-01-22 15:12:28 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5603