Created
April 23, 2014 17:38
-
-
Save guilhermeblanco/11225488 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php | |
index c49b978..eb70f3b 100644 | |
--- a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php | |
+++ b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php | |
@@ -263,7 +263,7 @@ abstract class AbstractHydrator | |
$cache[$key]['isIdentifier'] = $classMetadata->isIdentifier($fieldName); | |
$cache[$key]['dqlAlias'] = $this->_rsm->columnOwnerMap[$key]; | |
break; | |
- | |
+ | |
case (isset($this->_rsm->newObjectMappings[$key])): | |
// WARNING: A NEW object is also a scalar, so it must be declared before! | |
$mapping = $this->_rsm->newObjectMappings[$key]; | |
@@ -300,7 +300,7 @@ abstract class AbstractHydrator | |
continue 2; | |
} | |
} | |
- | |
+ | |
switch (true) { | |
case (isset($cache[$key]['isNewObjectParameter'])): | |
$fieldName = $cache[$key]['fieldName']; | |
@@ -311,38 +311,38 @@ abstract class AbstractHydrator | |
$rowData['newObjects'][$objIndex]['class'] = $cache[$key]['class']; | |
$rowData['newObjects'][$objIndex]['args'][$argIndex] = $value; | |
- | |
+ | |
$rowData['scalars'][$fieldName] = $value; | |
break; | |
- | |
+ | |
case (isset($cache[$key]['isScalar'])): | |
$value = $cache[$key]['type']->convertToPHPValue($value, $this->_platform); | |
$rowData['scalars'][$cache[$key]['fieldName']] = $value; | |
break; | |
- | |
+ | |
case (isset($cache[$key]['isMetaColumn'])): | |
$dqlAlias = $cache[$key]['dqlAlias']; | |
$fieldName = $cache[$key]['fieldName']; | |
- | |
+ | |
// Avoid double setting or null assignment | |
if (isset($rowData[$dqlAlias][$fieldName]) || $value === null) { | |
break; | |
} | |
- | |
+ | |
if ($cache[$key]['isIdentifier']) { | |
$id[$dqlAlias] .= '|' . $value; | |
$nonemptyComponents[$dqlAlias] = true; | |
} | |
- | |
+ | |
$rowData[$dqlAlias][$fieldName] = $value; | |
break; | |
- | |
+ | |
default: | |
$dqlAlias = $cache[$key]['dqlAlias']; | |
$fieldName = $cache[$key]['fieldName']; | |
$type = $cache[$key]['type']; | |
- | |
+ | |
// in an inheritance hierarchy the same field could be defined several times. | |
// We overwrite this value so long we don't have a non-null value, that value we keep. | |
// Per definition it cannot be that a field is defined several times and has several values. | |
@@ -353,13 +353,13 @@ abstract class AbstractHydrator | |
if ($cache[$key]['isIdentifier']) { | |
$id[$dqlAlias] .= '|' . $value; | |
} | |
- | |
+ | |
$value = $type->convertToPHPValue($value, $this->_platform); | |
- | |
+ | |
if ( ! isset($nonemptyComponents[$dqlAlias]) && $value !== null) { | |
$nonemptyComponents[$dqlAlias] = true; | |
} | |
- | |
+ | |
$rowData[$dqlAlias][$fieldName] = $value; | |
break; | |
} | |
@@ -392,6 +392,7 @@ abstract class AbstractHydrator | |
// NOTE: During scalar hydration, most of the times it's a scalar mapping, keep it first!!! | |
case (isset($this->_rsm->scalarMappings[$key])): | |
$cache[$key]['fieldName'] = $this->_rsm->scalarMappings[$key]; | |
+ $cache[$key]['type'] = Type::getType($this->_rsm->typeMappings[$key]); | |
$cache[$key]['isScalar'] = true; | |
break; | |
@@ -422,17 +423,25 @@ abstract class AbstractHydrator | |
switch (true) { | |
case (isset($cache[$key]['isScalar'])): | |
+ $type = $cache[$key]['type']; | |
+ $value = $type->convertToPHPValue($value, $this->_platform); | |
+ | |
$rowData[$fieldName] = $value; | |
break; | |
case (isset($cache[$key]['isMetaColumn'])): | |
- $rowData[$cache[$key]['dqlAlias'] . '_' . $fieldName] = $value; | |
+ $dqlAlias = $cache[$key]['dqlAlias']; | |
+ | |
+ $rowData[$dqlAlias . '_' . $fieldName] = $value; | |
break; | |
default: | |
- $value = $cache[$key]['type']->convertToPHPValue($value, $this->_platform); | |
+ $dqlAlias = $cache[$key]['dqlAlias']; | |
+ $type = $cache[$key]['type']; | |
+ $value = $type->convertToPHPValue($value, $this->_platform); | |
- $rowData[$cache[$key]['dqlAlias'] . '_' . $fieldName] = $value; | |
+ $rowData[$dqlAlias . '_' . $fieldName] = $value; | |
+ break; | |
} | |
} | |
@@ -454,7 +463,7 @@ abstract class AbstractHydrator | |
{ | |
if ($class->isIdentifierComposite) { | |
$id = array(); | |
- | |
+ | |
foreach ($class->identifier as $fieldName) { | |
$id[$fieldName] = isset($class->associationMappings[$fieldName]) | |
? $data[$class->associationMappings[$fieldName]['joinColumns'][0]['name']] | |
diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php | |
index f2fe56f..52b335d 100644 | |
--- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php | |
+++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php | |
@@ -38,13 +38,21 @@ class DDC657Test extends \Doctrine\Tests\OrmFunctionalTestCase | |
$this->assertCount(2,$result); | |
- $this->assertContains('11:11:11', $result[0]['time']); | |
- $this->assertContains('2010-01-01', $result[0]['date']); | |
- $this->assertContains('2010-01-01 11:11:11', $result[0]['datetime']); | |
+ $this->assertInstanceOf('DateTime', $result[0]['datetime']); | |
+ $this->assertInstanceOf('DateTime', $result[0]['time']); | |
+ $this->assertInstanceOf('DateTime', $result[0]['date']); | |
+ | |
+ $this->assertEquals('11:11:11', $result[0]['time']->format('H:i:s')); | |
+ $this->assertEquals('2010-01-01', $result[0]['date']->format('Y-m-d')); | |
+ $this->assertEquals('2010-01-01 11:11:11', $result[0]['datetime']->format('Y-m-d H:i:s')); | |
+ | |
+ $this->assertInstanceOf('DateTime', $result[1]['datetime']); | |
+ $this->assertInstanceOf('DateTime', $result[1]['time']); | |
+ $this->assertInstanceOf('DateTime', $result[1]['date']); | |
- $this->assertContains('12:12:12', $result[1]['time']); | |
- $this->assertContains('2010-02-02', $result[1]['date']); | |
- $this->assertContains('2010-02-02 12:12:12', $result[1]['datetime']); | |
+ $this->assertEquals('12:12:12', $result[1]['time']->format('H:i:s')); | |
+ $this->assertEquals('2010-02-02', $result[1]['date']->format('Y-m-d')); | |
+ $this->assertEquals('2010-02-02 12:12:12', $result[1]['datetime']->format('Y-m-d H:i:s')); | |
} | |
public function testaTicketEntityArrayResult() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment