DDC-952 - Fix bug in inverse one-to-one eager loading sql code.
This commit is contained in:
parent
4677883acd
commit
7c7106b1c1
@ -1031,7 +1031,7 @@ class BasicEntityPersister
|
|||||||
|
|
||||||
foreach ($owningAssoc['sourceToTargetKeyColumns'] AS $sourceCol => $targetCol) {
|
foreach ($owningAssoc['sourceToTargetKeyColumns'] AS $sourceCol => $targetCol) {
|
||||||
$this->_selectJoinSql .= $this->_getSQLTableAlias($owningAssoc['sourceEntity'], $assocAlias) . '.'.$sourceCol.' = ' .
|
$this->_selectJoinSql .= $this->_getSQLTableAlias($owningAssoc['sourceEntity'], $assocAlias) . '.'.$sourceCol.' = ' .
|
||||||
$this->_getSQLTableAlias($assoc['targetEntity']) . '.' . $targetCol . ' ';
|
$this->_getSQLTableAlias($owningAssoc['targetEntity']) . '.' . $targetCol . ' ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ class OneToOneEagerLoadingTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
|||||||
|
|
||||||
public function testEagerLoadOneToOneNullInverseSide()
|
public function testEagerLoadOneToOneNullInverseSide()
|
||||||
{
|
{
|
||||||
$driver = new TrainDriver("Benjamin");
|
$driver = new TrainDriver("Dagny Taggert");
|
||||||
|
|
||||||
$this->_em->persist($driver);
|
$this->_em->persist($driver);
|
||||||
$this->_em->flush();
|
$this->_em->flush();
|
||||||
@ -95,12 +95,26 @@ class OneToOneEagerLoadingTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
|||||||
$sqlCount = count($this->_sqlLoggerStack->queries);
|
$sqlCount = count($this->_sqlLoggerStack->queries);
|
||||||
|
|
||||||
$driver = $this->_em->find(get_class($driver), $driver->id);
|
$driver = $this->_em->find(get_class($driver), $driver->id);
|
||||||
var_dump($this->_sqlLoggerStack->queries); // wrong table aliasing!
|
|
||||||
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $driver->train);
|
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $driver->train);
|
||||||
$this->assertNull($driver->train);
|
$this->assertNull($driver->train);
|
||||||
|
|
||||||
$this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries));
|
$this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testEagerLoadManyToOne()
|
||||||
|
{
|
||||||
|
$train = new Train();
|
||||||
|
$waggon = new Waggon();
|
||||||
|
$train->addWaggon($waggon);
|
||||||
|
|
||||||
|
$this->_em->persist($train); // cascades
|
||||||
|
$this->_em->flush();
|
||||||
|
$this->_em->clear();
|
||||||
|
|
||||||
|
$waggon = $this->_em->find(get_class($waggon), $waggon->id);
|
||||||
|
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $waggon->train);
|
||||||
|
$this->assertNotNull($waggon->train);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -174,7 +188,7 @@ class Waggon
|
|||||||
{
|
{
|
||||||
/** @id @generatedValue @column(type="integer") */
|
/** @id @generatedValue @column(type="integer") */
|
||||||
public $id;
|
public $id;
|
||||||
/** @ManyToOne(targetEntity="Train", inversedBy="waggons") */
|
/** @ManyToOne(targetEntity="Train", inversedBy="waggons", fetch="EAGER") */
|
||||||
public $train;
|
public $train;
|
||||||
|
|
||||||
public function setTrain($train)
|
public function setTrain($train)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user