Finalized fix for scalars and newObjects.
This commit is contained in:
parent
9692fc8c5b
commit
f7de00b401
2 changed files with 15 additions and 39 deletions
|
@ -347,28 +347,28 @@ abstract class AbstractHydrator
|
|||
continue;
|
||||
}
|
||||
|
||||
$fieldName = $cache[$key]['fieldName'];
|
||||
$fieldName = $cacheKeyInfo['fieldName'];
|
||||
|
||||
switch (true) {
|
||||
case (isset($cache[$key]['isScalar'])):
|
||||
case (isset($cacheKeyInfo['isScalar'])):
|
||||
// WARNING: BC break! We know this is the desired behavior to type convert values, but this
|
||||
// erroneous behavior exists since 2.0 and we're forced to keep compatibility. For 3.0 release,
|
||||
// uncomment these 2 lines of code.
|
||||
//$type = $cache[$key]['type'];
|
||||
//$type = $cacheKeyInfo['type'];
|
||||
//$value = $type->convertToPHPValue($value, $this->_platform);
|
||||
|
||||
$rowData[$fieldName] = $value;
|
||||
break;
|
||||
|
||||
case (isset($cache[$key]['isMetaColumn'])):
|
||||
$dqlAlias = $cache[$key]['dqlAlias'];
|
||||
case (isset($cacheKeyInfo['isMetaColumn'])):
|
||||
$dqlAlias = $cacheKeyInfo['dqlAlias'];
|
||||
|
||||
$rowData[$dqlAlias . '_' . $fieldName] = $value;
|
||||
break;
|
||||
|
||||
default:
|
||||
$dqlAlias = $cache[$key]['dqlAlias'];
|
||||
$type = $cache[$key]['type'];
|
||||
$dqlAlias = $cacheKeyInfo['dqlAlias'];
|
||||
$type = $cacheKeyInfo['type'];
|
||||
$value = $type->convertToPHPValue($value, $this->_platform);
|
||||
|
||||
$rowData[$dqlAlias . '_' . $fieldName] = $value;
|
||||
|
|
|
@ -364,28 +364,6 @@ class ObjectHydrator extends AbstractHydrator
|
|||
// Split the row data into chunks of class data.
|
||||
$rowData = $this->gatherRowData($row, $cache, $id, $nonemptyComponents);
|
||||
|
||||
// Extract scalar values. They're appended at the end.
|
||||
if (isset($rowData['scalars'])) {
|
||||
$scalars = $rowData['scalars'];
|
||||
|
||||
unset($rowData['scalars']);
|
||||
|
||||
if (empty($rowData)) {
|
||||
++$this->resultCounter;
|
||||
}
|
||||
}
|
||||
|
||||
// Extract "new" object constructor arguments. They're appended at the end.
|
||||
if (isset($rowData['newObjects'])) {
|
||||
$newObjects = $rowData['newObjects'];
|
||||
|
||||
unset($rowData['newObjects']);
|
||||
|
||||
if (empty($rowData)) {
|
||||
++$this->resultCounter;
|
||||
}
|
||||
}
|
||||
|
||||
// Hydrate the data chunks
|
||||
foreach ($rowData['data'] as $dqlAlias => $data) {
|
||||
$entityName = $this->_rsm->aliasMap[$dqlAlias];
|
||||
|
@ -586,29 +564,27 @@ class ObjectHydrator extends AbstractHydrator
|
|||
}
|
||||
|
||||
// Append scalar values to mixed result sets
|
||||
if (isset($scalars)) {
|
||||
if (isset($rowData['scalars'])) {
|
||||
if ( ! isset($resultKey) ) {
|
||||
if (isset($this->_rsm->indexByMap['scalars'])) {
|
||||
$resultKey = $row[$this->_rsm->indexByMap['scalars']];
|
||||
} else {
|
||||
$resultKey = $this->resultCounter - 1;
|
||||
}
|
||||
$resultKey = (isset($this->_rsm->indexByMap['scalars']))
|
||||
? $row[$this->_rsm->indexByMap['scalars']]
|
||||
: $this->resultCounter - 1;
|
||||
}
|
||||
|
||||
foreach ($scalars as $name => $value) {
|
||||
foreach ($rowData['scalars'] as $name => $value) {
|
||||
$result[$resultKey][$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// Append new object to mixed result sets
|
||||
if (isset($newObjects)) {
|
||||
if (isset($rowData['newObjects'])) {
|
||||
if ( ! isset($resultKey) ) {
|
||||
$resultKey = $this->resultCounter - 1;
|
||||
}
|
||||
|
||||
$count = count($newObjects);
|
||||
$count = count($rowData['newObjects']);
|
||||
|
||||
foreach ($newObjects as $objIndex => $newObject) {
|
||||
foreach ($rowData['newObjects'] as $objIndex => $newObject) {
|
||||
$class = $newObject['class'];
|
||||
$args = $newObject['args'];
|
||||
$obj = $class->newInstanceArgs($args);
|
||||
|
|
Loading…
Add table
Reference in a new issue