Skip to content

Commit

Permalink
Merge branch 'DDC-1964'
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed Jul 29, 2012
2 parents bcbef56 + 7c1235d commit e8d3fc7
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ protected function hydrateRowData(array $row, array &$cache, array &$result)
$this->_resultPointers[$dqlAlias] = $element;
} else {
$this->_uow->setOriginalEntityProperty($oid, $relationField, null);
$reflField->setValue($parentObject, null);
}
// else leave $reflFieldValue null for single-valued associations
} else {
Expand Down
36 changes: 36 additions & 0 deletions tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ protected function setUp()
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainDriver'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainOwner'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Waggon'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainOrder'),
));
} catch(\Exception $e) {}
}
Expand Down Expand Up @@ -181,6 +182,24 @@ public function testEagerLoadWithNonNullableColumnsGeneratesLeftJoinOnNonOwningS
$this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery]['sql']
);
}

/**
* @group DDC-1946
*/
public function testEagerLoadingDoesNotBreakRefresh()
{
$train = new Train(new TrainOwner('Johannes'));
$order = new TrainOrder($train);
$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->assertTrue($order->train === null, "Train reference was not refreshed to NULL.");
}
}

/**
Expand Down Expand Up @@ -305,3 +324,20 @@ public function setTrain($train)
$this->train = $train;
}
}

/**
* @Entity
*/
class TrainOrder
{
/** @id @generatedValue @column(type="integer") */
public $id;

/** @OneToOne(targetEntity = "Train", fetch = "EAGER") */
public $train;

public function __construct(Train $train)
{
$this->train = $train;
}
}
3 changes: 3 additions & 0 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

require_once __DIR__ . '/../../../TestInit.php';

/**
* @group DDC-371
*/
class DDC371Test extends \Doctrine\Tests\OrmFunctionalTestCase
{
protected function setUp()
Expand Down

0 comments on commit e8d3fc7

Please sign in to comment.