1
0
mirror of synced 2024-12-13 06:46:03 +03:00

Fix DDC-2478

This commit is contained in:
Fabio B. Silva 2013-06-13 16:21:26 -04:00 committed by fabios
parent 6ef48561ba
commit f16c8e3efe
2 changed files with 30 additions and 0 deletions

View File

@ -66,6 +66,7 @@ class SqlExpressionVisitor extends ExpressionVisitor
$value = $comparison->getValue()->getValue(); // shortcut for walkValue()
if (isset($this->classMetadata->associationMappings[$field]) &&
$value !== null &&
! is_object($value) &&
! in_array($comparison->getOperator(), array(Comparison::IN, Comparison::NIN))) {

View File

@ -842,6 +842,35 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals(2, count($users));
}
/**
* @group DDC-2478
*/
public function testMatchingCriteriaNullAssocComparison()
{
$fixtures = $this->loadFixtureUserEmail();
$user = $this->_em->merge($fixtures[0]);
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$criteriaIsNull = Criteria::create()->where(Criteria::expr()->isNull('email'));
$criteriaEqNull = Criteria::create()->where(Criteria::expr()->eq('email', null));
$user->setEmail(null);
$this->_em->persist($user);
$this->_em->flush();
$this->_em->clear();
$usersIsNull = $repository->matching($criteriaIsNull);
$usersEqNull = $repository->matching($criteriaEqNull);
$this->assertCount(1, $usersIsNull);
$this->assertCount(1, $usersEqNull);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $usersIsNull[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $usersEqNull[0]);
$this->assertNull($usersIsNull[0]->getEmail());
$this->assertNull($usersEqNull[0]->getEmail());
}
/**
* @group DDC-2055
*/