Changeset 4993

Show
Ignore:
Timestamp:
09/26/08 21:14:01 (3 months ago)
Author:
jwage
Message:

[1.0] fixes #1380 Hydrating calculated columns to base component

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/1.0/lib/Doctrine/Hydrator.php

    r4831 r4993  
    3434class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract 
    3535{ 
     36    protected $_rootAlias = null; 
    3637    /** 
    3738     * hydrateResultSet 
     
    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 
     
    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 
     
    330334                $rowData[$dqlAlias][$fieldName] = $table->prepareValue( 
    331335                        $fieldName, $value, $cache[$key]['type']); 
     336            } 
     337 
     338            // Ticket #1380 
     339            // Hydrate aggregates in to the root component as well. 
     340            // So we know that all aggregate values will always be available in the root component 
     341            if ($agg) { 
     342                $rowData[$this->_rootAlias][$fieldName] = $rowData[$dqlAlias][$fieldName]; 
    332343            } 
    333344