mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-258: DiscriminatorMap Ordering Affects Mapping #318
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.