From c47a072815123b127697b85ac7c676d1a7a3ed62 Mon Sep 17 00:00:00 2001 From: jaimz22 Date: Sat, 8 Nov 2014 16:36:55 +0000 Subject: [PATCH] fixed for failing test case. when a single DTO is specified in the query, you no longer get a multidimensional array returned. --- lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php | 5 +++-- lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php index 507fd7025..f63337b1c 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php @@ -246,14 +246,15 @@ class ArrayHydrator extends AbstractHydrator $resultKey = $this->_resultCounter - 1; } - $count = count($rowData['newObjects']); + $scalarCount = (isset($rowData['scalars'])? count($rowData['scalars']): 0); foreach ($rowData['newObjects'] as $objIndex => $newObject) { $class = $newObject['class']; $args = $newObject['args']; $obj = $class->newInstanceArgs($args); - if ($count === 1) { + // if ($count === 1) { + if (count($args) == $scalarCount || ($scalarCount == 0 && count($rowData['newObjects'])) { $result[$resultKey] = $obj; continue; diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index 1dfbfc441..5a44e6689 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -553,7 +553,8 @@ class ObjectHydrator extends AbstractHydrator $args = $newObject['args']; $obj = $class->newInstanceArgs($args); - if (count($args) == $scalarCount) { + // if (count($args) == $scalarCount) { + if (count($args) == $scalarCount || ($scalarCount == 0 && count($rowData['newObjects']))) { $result[$resultKey] = $obj; continue;