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

Fix regression in DDC-2430.

This commit is contained in:
Benjamin Eberlei 2013-05-10 23:31:14 +02:00
parent bf9673203c
commit eb1a162cbc
2 changed files with 28 additions and 2 deletions

View File

@ -65,7 +65,10 @@ class SqlExpressionVisitor extends ExpressionVisitor
$field = $comparison->getField();
$value = $comparison->getValue()->getValue(); // shortcut for walkValue()
if (isset($this->classMetadata->associationMappings[$field]) && ! is_object($value)) {
if (isset($this->classMetadata->associationMappings[$field]) &&
! is_object($value) &&
! in_array($comparison->getOperator(), array(Comparison::IN, Comparison::NIN))) {
throw PersisterException::matchingAssocationFieldRequiresObject($this->classMetadata->name, $field);
}

View File

@ -790,7 +790,30 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $userId);
$criteria = new Criteria(
Criteria::expr()->gte('user', $user)
Criteria::expr()->eq('user', $user)
);
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress');
$addresses = $repository->matching($criteria);
$this->assertEquals(1, count($addresses));
$addresses = new ArrayCollection($repository->findAll());
$this->assertEquals(1, count($addresses->matching($criteria)));
}
/**
* @group DDC-2430
*/
public function testMatchingCriteriaAssocationInWithArray()
{
list($userId, $addressId) = $this->loadAssociatedFixture();
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $userId);
$criteria = new Criteria(
Criteria::expr()->in('user', array($user))
);
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress');