From a7aa6342471d339930e66c374888cf93b823acf8 Mon Sep 17 00:00:00 2001 From: Ulf Date: Tue, 17 Jun 2014 14:51:19 +0200 Subject: [PATCH] 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. --- lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php index 124b099c7..ea2664291 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php @@ -75,6 +75,11 @@ class SimpleObjectHydrator extends AbstractHydrator if ($this->class->inheritanceType !== ClassMetadata::INHERITANCE_TYPE_NONE) { $discrColumnName = $this->_platform->getSQLResultCasing($this->class->discriminatorColumn['name']); + // Find mapped discriminator column from the result set. + if ($metaMappingDiscrColumnName = array_search($discrColumnName, $this->_rsm->metaMappings)) { + $discrColumnName = $metaMappingDiscrColumnName; + } + if ( ! isset($sqlResult[$discrColumnName])) { throw HydrationException::missingDiscriminatorColumn($entityName, $discrColumnName, key($this->_rsm->aliasMap)); }