Changeset 3630

Show
Ignore:
Timestamp:
01/25/08 07:14:07 (18 months ago)
Author:
dbrewer
Message:

#749: fixed issue with hydrating rows of a result set when column
aggregation inheritence is involved.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/0.9/lib/Doctrine/Hydrate.php

    r3546 r3630  
    10631063            $prev[$alias] = array(); 
    10641064            $id[$alias] = ''; 
     1065             
     1066            $subclassMap[$alias] = array(); 
     1067            $subclassInheritanceMap = array(); 
     1068             
     1069            // cache record listeners for subclasses of all involved tables 
     1070            if ($subclasses = $data['table']->subclasses) { 
     1071                $subclassMap[$alias] = $subclasses; 
     1072 
     1073                foreach ($subclasses as $subclass) { 
     1074                    if ($componentName != $subclass) { 
     1075                        $subclass_table = $this->_conn->getTable($subclass); 
     1076                        $listeners[$subclass] = $subclass_table->getRecordListener(); 
     1077                        $subclassInheritanceMap[$subclass] = $subclass_table->inheritanceMap; 
     1078                    } 
     1079               } 
     1080            } 
    10651081        } 
    10661082 
     
    11031119            // dealing with root component 
    11041120            $table = $this->_aliasMap[$rootAlias]['table']; 
    1105             $componentName = $table->getComponentName(); 
     1121 
     1122            // check if this matches any subclasses 
     1123            $componentName = false; 
     1124            foreach ($subclassMap[$rootAlias] as $subclass) { 
     1125                if (array_key_exists($subclass, $subclassInheritanceMap)) { 
     1126                    foreach ($subclassInheritanceMap[$subclass] as $key => $value) { 
     1127                        if (isset($currData[$rootAlias][$key]) && $currData[$rootAlias][$key] == $value) { 
     1128                            $subclass_table = $this->_conn->getTable($subclass); 
     1129                            $componentName = $subclass_table->getComponentName(); 
     1130                        } 
     1131                    } 
     1132                } 
     1133            } 
     1134 
     1135            // if it didn't match any subclasses, just use the name of the table 
     1136            if (!$componentName) $componentName = $table->getComponentName(); 
     1137 
    11061138            $event->set('data', $currData[$rootAlias]); 
    11071139            $listeners[$componentName]->preHydrate($event);