Fix DDC-2478
This commit is contained in:
parent
6ef48561ba
commit
f16c8e3efe
@ -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))) {
|
||||
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user