mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-258: DiscriminatorMap Ordering Affects Mapping #320
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 (Jan 15, 2010).
Jira issue originally created by user mridgway:
In an inheritance tree, I have a super class with three subclasses. Two of the subclasses have a 'title' and 'description' field, but one of those has an extra field. The third class doesn't share any properties, but demonstrates the reasoning for not having 'title' and 'description' in the super class.
So, the problem I'm getting is that only one of these classes can work at a time, depending on which is first in the DiscriminatorMap. The SQL query performs left joins on all of the tables and uses aliases to keep the common fields separated. The mapper doesn't seem to be using the aliases when it maps the properties to the object. It seems override properties even if they aren't in the correct table.
Example:
The select for a Super of id 2 uses the following query (or similar):
noneSELECT t0.id, t0.type, t1.title, t1.description, t2.title, t2.description, t2.text, t3.apples, t3.bananas FROM Super t0 LEFT JOIN Class1 t1 ON t0.id = t1.id LEFT JOIN Class2 t2 ON t0.id = t2.id LEFT JOIN Class3 t3 ON t0.id = t3.id WHERE t0.id = 2;Now, if the DiscriminatorMap is reordered, the joins change order as well, which seems to affect which fields actually get mapped to the object.
@doctrinebot commented on GitHub (Jan 18, 2010):
Comment created by mridgway:
It appears it doesn't have to do with the table name, but with the actual property name. Changing the property column names in one of the classes still gives the same results, but changing the property names does fix it.
@doctrinebot commented on GitHub (Jan 18, 2010):
Comment created by mridgway:
Formatting to fix horizontal scroll.
@doctrinebot commented on GitHub (Feb 20, 2010):
Comment created by @beberlei:
@Roman - I just read jwages slides on Dc2 and he mentioned in an inheritance scenario no field is allowed to be defined twice, isn't that the case here which produces this problems?
@doctrinebot commented on GitHub (Feb 22, 2010):
Comment created by romanb:
@Benjamin: Shouldnt be, because the restriction refers to classes who inherit from each other.
Say, if Class2 would extend Class1 in this example, that would be a violation because Class2 would actually have 2 x title/description.
@doctrinebot commented on GitHub (Feb 26, 2010):
Comment created by @beberlei:
Verified, Test-Case attached for Roman
@doctrinebot commented on GitHub (Mar 5, 2010):
Comment created by romanb:
Should be fixed now. Testcase is committed.
@doctrinebot commented on GitHub (Mar 5, 2010):
Issue was closed with resolution "Fixed"
@doctrinebot commented on GitHub (Dec 13, 2015):
Imported 1 attachments from Jira into https://gist.github.com/778b3c6ba10e47829bc6