JOINED inheritance not permitting mapping the same column name from both child and parent tables #5903

Closed
opened 2026-01-22 15:21:35 +01:00 by admin · 2 comments
Owner

Originally created by @chewett on GitHub (Feb 26, 2018).

I have a JOINED inheritance mapping where the parent maps the column foo (which belongs to the parent table) with the variable name $parentfoo,

The child then maps the column foo (which belongs to the child table) with the variable name $childfoo.

When I try using this variable doctrine fails with the error "Duplicate definition of column 'foo' on entity 'ChildFooEntity'"

Am I correct in believing that doctrine doesnt support mapping columns with the same name from the parent and child?

I have googled around but cant find any reference to this one way or another. However checking the doctrine code:

if (isset($this->fieldNames[$mapping['columnName']]) || ($this->discriminatorColumn != null && $this->discriminatorColumn['name'] == $mapping['columnName'])) {

Its clearly being checked and rejected. Are there any suggestions about how I can map foo in both tables?

Or is it just not possible and I should change the column names?

Originally created by @chewett on GitHub (Feb 26, 2018). I have a JOINED inheritance mapping where the parent maps the column `foo` (which belongs to the parent table) with the variable name `$parentfoo`, The child then maps the column `foo` (which belongs to the child table) with the variable name `$childfoo`. When I try using this variable doctrine fails with the error "Duplicate definition of column 'foo' on entity 'ChildFooEntity'" Am I correct in believing that doctrine doesnt support mapping columns with the same name from the parent and child? I have googled around but cant find any reference to this one way or another. However checking the doctrine code: `if (isset($this->fieldNames[$mapping['columnName']]) || ($this->discriminatorColumn != null && $this->discriminatorColumn['name'] == $mapping['columnName'])) {` Its clearly being checked and rejected. Are there any suggestions about how I can map foo in both tables? Or is it just not possible and I should change the column names?
admin closed this issue 2026-01-22 15:21:36 +01:00
Author
Owner

@Ocramius commented on GitHub (Feb 26, 2018):

We don't expect to support same column names within a same inheritance: it can lead to too many tricky scenarios due to resultset key collisions that we didn't design against.

@Ocramius commented on GitHub (Feb 26, 2018): We don't expect to support same column names within a same inheritance: it can lead to too many tricky scenarios due to resultset key collisions that we didn't design against.
Author
Owner

@chewett commented on GitHub (Feb 26, 2018):

Ok many thanks for the clarification. I will look at getting our DB structure changed.

@chewett commented on GitHub (Feb 26, 2018): Ok many thanks for the clarification. I will look at getting our DB structure changed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5903