1
0
mirror of synced 2025-01-18 22:41:43 +03:00

fix DDC-142 load OneToOne EAGER

This commit is contained in:
Fabio B. Silva 2012-06-11 18:21:22 -03:00
parent cd806b83db
commit e0a236a9af
2 changed files with 37 additions and 8 deletions

View File

@ -1048,7 +1048,10 @@ class BasicEntityPersister
$this->_selectJoinSql .= ' ' . $this->quoteStrategy->getTableName($eagerEntity) . ' ' . $this->_getSQLTableAlias($eagerEntity->name, $assocAlias) .' ON ';
$tableAlias = $this->_getSQLTableAlias($assoc['targetEntity'], $assocAlias);
foreach ($assoc['sourceToTargetKeyColumns'] as $sourceCol => $targetCol) {
foreach ($assoc['joinColumns'] as $joinColumn) {
$sourceCol = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class);
$targetCol = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $this->_class);
if ( ! $first) {
$this->_selectJoinSql .= ' AND ';
}

View File

@ -18,8 +18,6 @@ class DDC142Test extends \Doctrine\Tests\OrmFunctionalTestCase
{
parent::setUp();
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
try {
$this->_schemaTool->createSchema(array(
$this->_em->getClassMetadata('Doctrine\Tests\Models\Quote\User'),
@ -28,9 +26,7 @@ class DDC142Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->getClassMetadata('Doctrine\Tests\Models\Quote\Address'),
));
} catch(\Exception $e) {
//$this->fail($e->getMessage());
}
}
public function testCreateRetreaveUpdateDelete()
@ -53,11 +49,41 @@ class DDC142Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->flush();
$this->_em->clear();
$this->assertNotNull($user->id);
$this->markTestIncomplete();
$id = $user->id;
$this->assertNotNull($id);
$user = $this->_em->find('Doctrine\Tests\Models\Quote\User', $user->id);
$user = $this->_em->find('Doctrine\Tests\Models\Quote\User', $id);
$address = $user->getAddress();
$this->assertInstanceOf('Doctrine\Tests\Models\Quote\User', $user);
$this->assertInstanceOf('Doctrine\Tests\Models\Quote\Address', $user->getAddress());
$this->assertEquals('FabioBatSilva', $user->name);
$this->assertEquals('12345', $address->zip);
$user->name = 'FabioBatSilva1';
$user->address = null;
$this->_em->persist($user);
$this->_em->remove($address);
$this->_em->flush();
$this->_em->clear();
$user = $this->_em->find('Doctrine\Tests\Models\Quote\User', $id);
$this->assertInstanceOf('Doctrine\Tests\Models\Quote\User', $user);
$this->assertNull($user->getAddress());
$this->assertEquals('FabioBatSilva1', $user->name);
$this->_em->remove($user);
$this->_em->flush();
$this->_em->clear();
$this->assertNull($this->_em->find('Doctrine\Tests\Models\Quote\User', $id));
}
}