mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-827: Class Table Inheritance is broken when child classes have the same properties #1020
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 @doctrinebot on GitHub (Oct 6, 2010).
Jira issue originally created by user nicokaiser:
I create one Superclass and several Subclasses. The subclasses have properties with the same name (but as I also want to have Subclasses without these properties, this is the only elegant construction), in this example "name".
Now when I select the Superclass, I get all Subclass entities, but the "name" property is not hydrated correctly:
Output:
The SQL however seems correct, both(!) "name" columns are selected. This seems to be a bug in hydration.
@doctrinebot commented on GitHub (Oct 6, 2010):
Comment created by @beberlei:
Quoting from the Docs, chapter "Architecture" on the requirements of entities (and inheritance):
@doctrinebot commented on GitHub (Oct 6, 2010):
Issue was closed with resolution "Invalid"
@doctrinebot commented on GitHub (Nov 5, 2010):
Comment created by literal:
Please reopen this issue. I can can confirm it and Benjamin's reason for rejecting it is invalid.
The two classes in the example are in neither directly nor indirectly inheriting from one another. They just happen to be siblings, i. e. they have the same superclass.
And to pre-empt the argument: It is not always bad design to have two classes in a hierarchy that have an identically named property. At least as long as PHP does not allow for horizontal re-use via traits or such.
Take this scenario:
Now if the need arises to have a property 'foo' on both SubSubClass1 and SubSubClass4, and 'foo' shall not be part of the top-most super class, because it makes no sense in any of the other classes, then we unfortunately have to repeat ourselves or employ some bad magic which certainly cannot be mapped with Doctrine anyway.
@doctrinebot commented on GitHub (Nov 5, 2010):
Comment created by @beberlei:
There is another open issue that handles this issue. Its indeed a bug.