1
0
mirror of synced 2025-01-18 06:21:40 +03:00

[DDC-1777] Fix bug in BasicEntityPersister#exists() when no primary key is set.

This commit is contained in:
Benjamin Eberlei 2012-05-27 17:11:21 +02:00
parent c1fd0c479a
commit 6523f7f59e
2 changed files with 23 additions and 0 deletions

View File

@ -1524,6 +1524,10 @@ class BasicEntityPersister
{
$criteria = $this->_class->getIdentifierValues($entity);
if ( ! $criteria) {
return false;
}
if ($extraConditions) {
$criteria = array_merge($criteria, $extraConditions);
}

View File

@ -448,4 +448,23 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $manager->getId());
$this->assertEquals(1, count($manager->getFriends()));
}
/**
* @group DDC-1777
*/
public function testExistsSubclass()
{
$manager = new CompanyManager();
$manager->setName('gblanco');
$manager->setSalary(1234);
$manager->setTitle('Awesome!');
$manager->setDepartment('IT');
$this->assertFalse($this->_em->getUnitOfWork()->getEntityPersister(get_class($manager))->exists($manager));
$this->_em->persist($manager);
$this->_em->flush();
$this->assertTrue($this->_em->getUnitOfWork()->getEntityPersister(get_class($manager))->exists($manager));
}
}