Ticket #1380: 1380.diff

File 1380.diff, 1.7 KB (added by jwage, 19 months ago)
  • lib/Doctrine/Hydrator.php

     
    3333 */ 
    3434class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract 
    3535{ 
     36    protected $_rootAlias = null; 
    3637    /** 
    3738     * hydrateResultSet 
    3839     * parses the data returned by statement object 
     
    7677        // Used variables during hydration 
    7778        reset($this->_queryComponents); 
    7879        $rootAlias = key($this->_queryComponents); 
     80        $this->_rootAlias = $rootAlias; 
    7981        $rootComponentName = $this->_queryComponents[$rootAlias]['table']->getComponentName(); 
    8082        // if only one component is involved we can make our lives easier 
    8183        $isSimpleQuery = count($this->_queryComponents) <= 1; 
     
    316318            $table = $map['table']; 
    317319            $dqlAlias = $cache[$key]['dqlAlias']; 
    318320            $fieldName = $cache[$key]['fieldName']; 
     321            $agg = false; 
    319322            if (isset($this->_queryComponents[$dqlAlias]['agg'][$fieldName])) { 
    320323                $fieldName = $this->_queryComponents[$dqlAlias]['agg'][$fieldName]; 
     324                $agg = true; 
    321325            } 
    322326 
    323327            if ($cache[$key]['isIdentifier']) { 
     
    331335                        $fieldName, $value, $cache[$key]['type']); 
    332336            } 
    333337 
     338            // Ticket #1380 
     339            if ($agg) { 
     340                $rowData[$this->_rootAlias][$fieldName] = $rowData[$dqlAlias][$fieldName]; 
     341            } 
     342 
    334343            if ( ! isset($nonemptyComponents[$dqlAlias]) && $value !== null) { 
    335344                $nonemptyComponents[$dqlAlias] = true; 
    336345            }