#1551: Subclass of column aggregation inheritance returns parent class instead
of
subclass
------------------------------+---------------------------------------------
Reporter: chorizo | Owner: romanb
Type: defect | Status: closed
Priority: minor | Milestone: 1.0.3
Component: Query/Hydration | Version: 1.0.2
Resolution: invalid | Keywords:
Has_test: 0 | Mystatus: Pending Core Response
Has_patch: 1 |
------------------------------+---------------------------------------------
Comment (by chorizo):
I'm not a huge fan of making all of those classes final, which is what
ends up happening. I still think there is an issue to be solved. I could
add the next subclass to the inheritance map with the same type, but
_getClassnameToReturn doesn't have any means of prioritizing one over the
other.
I guess it could be changed to:
1) look to see if $component is in the inheritanceMap
2) see if $component matches the inheritanceMap criteria, if so, return it
3) continue on to the current codepath
If a parent class is used as $component, the other of the inheritanceMap
would determine the class returned (as it currently does, if you tried to
use it this way).
How about something like this:
{{{
if (in_array($component, $subclasses)) {
$table = Doctrine::getTable($subclass);
$inheritanceMap = $table->getOption('inheritanceMap');
list($key, $value) = each($inheritanceMap);
if ( isset($data[$key]) && $data[$key] == $value) {
return $table->getComponentName();
}
}}}
This basically trades an in_array for the is_subclass_of. In cases where
you are passing a valid subclass, it doesn't walk through the subclasses
array, in cases where you pass in a parent class, it does a failing
in_array
--
Ticket URL: <http://trac.doctrine-project.org/ticket/1551#comment:3>
Doctrine <http://www.phpdoctrine.org>
PHP Doctrine Object Relational Mapper
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"doctrine-svn" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.co.uk/group/doctrine-svn?hl=en-GB
-~----------~----~----~----~------~----~------~--~---