From 7c1235dedb8364eaf8b145bc542e6016e5db605e Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sun, 29 Jul 2012 11:25:45 +0200 Subject: [PATCH] [DDC-1964] Fix issue with refresh and and object hydrator not setting field to null explicitly to override possible previous values. --- .../ORM/Internal/Hydration/ObjectHydrator.php | 1 + .../ORM/Functional/OneToOneEagerLoadingTest.php | 15 +++++++++------ .../Tests/ORM/Functional/Ticket/DDC371Test.php | 3 +++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index 5813734cd..3f48f8607 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -448,6 +448,7 @@ class ObjectHydrator extends AbstractHydrator $this->_resultPointers[$dqlAlias] = $element; } else { $this->_uow->setOriginalEntityProperty($oid, $relationField, null); + $reflField->setValue($parentObject, null); } // else leave $reflFieldValue null for single-valued associations } else { diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php index 7c5a76c65..7ad30ab7a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php @@ -182,7 +182,10 @@ class OneToOneEagerLoadingTest extends \Doctrine\Tests\OrmFunctionalTestCase $this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery]['sql'] ); } - + + /** + * @group DDC-1946 + */ public function testEagerLoadingDoesNotBreakRefresh() { $train = new Train(new TrainOwner('Johannes')); @@ -190,12 +193,12 @@ class OneToOneEagerLoadingTest extends \Doctrine\Tests\OrmFunctionalTestCase $this->_em->persist($train); $this->_em->persist($order); $this->_em->flush(); - + $this->_em->getConnection()->exec("UPDATE TrainOrder SET train_id = NULL"); - + $this->assertSame($train, $order->train); $this->_em->refresh($order); - $this->assertNull($order->train); + $this->assertTrue($order->train === null, "Train reference was not refreshed to NULL."); } } @@ -332,9 +335,9 @@ class TrainOrder /** @OneToOne(targetEntity = "Train", fetch = "EAGER") */ public $train; - + public function __construct(Train $train) { $this->train = $train; } -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php index 54f76b1a7..2a99519cb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php @@ -5,6 +5,9 @@ use Doctrine\ORM\Query; require_once __DIR__ . '/../../../TestInit.php'; +/** + * @group DDC-371 + */ class DDC371Test extends \Doctrine\Tests\OrmFunctionalTestCase { protected function setUp()