1
0
mirror of synced 2025-02-20 06:03:15 +03:00

Merge branch 'DDC-1964'

This commit is contained in:
Benjamin Eberlei 2012-07-29 11:25:54 +02:00
commit e8d3fc73ff
3 changed files with 40 additions and 0 deletions

View File

@ -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 {

View File

@ -21,6 +21,7 @@ class OneToOneEagerLoadingTest extends \Doctrine\Tests\OrmFunctionalTestCase
$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) {}
}
@ -181,6 +182,24 @@ 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'));
$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.");
}
}
/**
@ -305,3 +324,20 @@ class Waggon
$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;
}
}

View File

@ -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()