Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a7aa634

Browse files
committed
Fixed mapping of discriminator column
Added fix for [DDC-3170] (http://www.doctrine-project.org/jira/browse/DDC-3170). When querying a simple entity which uses single table- or class table inheritance using simple object hydration (``AbstractQuery::HYDRATE_SIMPLEOBJECT``), the mapped discriminator column was not retrieved correctly. If the column got an alias during result set mapping other than it's actual name (e.g. ``type34`` insteaad of ``type``) than this alias wasn't reverted when retrieving the discriminator column from the SQL result set.
1 parent 7aa1c0a commit a7aa634

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ protected function hydrateRowData(array $sqlResult, array &$result)
7575
if ($this->class->inheritanceType !== ClassMetadata::INHERITANCE_TYPE_NONE) {
7676
$discrColumnName = $this->_platform->getSQLResultCasing($this->class->discriminatorColumn['name']);
7777

78+
// Find mapped discriminator column from the result set.
79+
if ($metaMappingDiscrColumnName = array_search($discrColumnName, $this->_rsm->metaMappings)) {
80+
$discrColumnName = $metaMappingDiscrColumnName;
81+
}
82+
7883
if ( ! isset($sqlResult[$discrColumnName])) {
7984
throw HydrationException::missingDiscriminatorColumn($entityName, $discrColumnName, key($this->_rsm->aliasMap));
8085
}

0 commit comments

Comments
 (0)