Skip to content

Commit

Permalink
[DDC-1777] Fix bug in BasicEntityPersister#exists() when no primary k…
Browse files Browse the repository at this point in the history
…ey is set.
  • Loading branch information
beberlei committed May 27, 2012
1 parent c1fd0c4 commit 6523f7f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Doctrine/ORM/Persisters/BasicEntityPersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,10 @@ public function exists($entity, array $extraConditions = array())
{
$criteria = $this->_class->getIdentifierValues($entity);

if ( ! $criteria) {
return false;
}

if ($extraConditions) {
$criteria = array_merge($criteria, $extraConditions);
}
Expand Down
19 changes: 19 additions & 0 deletions tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,4 +448,23 @@ public function testGetSubClassManyToManyCollection()
$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));
}
}

0 comments on commit 6523f7f

Please sign in to comment.