[DDC-1087] Add missing resolution to IS NULL in EntityRepository when passing a null value as a criteria.
This commit is contained in:
parent
db82ef3e61
commit
a329007526
@ -1206,7 +1206,7 @@ class BasicEntityPersister
|
|||||||
} else {
|
} else {
|
||||||
throw ORMException::unrecognizedField($field);
|
throw ORMException::unrecognizedField($field);
|
||||||
}
|
}
|
||||||
$conditionSql .= (is_array($value)) ? ' IN (?)' : ' = ?';
|
$conditionSql .= (is_array($value)) ? ' IN (?)' : (($value === null) ? ' IS NULL' : ' = ?');
|
||||||
}
|
}
|
||||||
return $conditionSql;
|
return $conditionSql;
|
||||||
}
|
}
|
||||||
@ -1291,6 +1291,10 @@ class BasicEntityPersister
|
|||||||
$params = $types = array();
|
$params = $types = array();
|
||||||
|
|
||||||
foreach ($criteria AS $field => $value) {
|
foreach ($criteria AS $field => $value) {
|
||||||
|
if ($value === null) {
|
||||||
|
continue; // skip null values.
|
||||||
|
}
|
||||||
|
|
||||||
$type = null;
|
$type = null;
|
||||||
if (isset($this->_class->fieldMappings[$field])) {
|
if (isset($this->_class->fieldMappings[$field])) {
|
||||||
$type = Type::getType($this->_class->fieldMappings[$field]['type'])->getBindingType();
|
$type = Type::getType($this->_class->fieldMappings[$field]['type'])->getBindingType();
|
||||||
|
@ -307,5 +307,18 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
|||||||
|
|
||||||
$repos->createNamedQuery('invalidNamedQuery');
|
$repos->createNamedQuery('invalidNamedQuery');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group DDC-1087
|
||||||
|
*/
|
||||||
|
public function testIsNullCriteria()
|
||||||
|
{
|
||||||
|
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
|
||||||
|
$users = $repos->findBy(array('status' => null, 'username' => 'romanb'));
|
||||||
|
|
||||||
|
$params = $this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery]['params'];
|
||||||
|
$this->assertEquals(1, count($params), "Should only execute with one parameter.");
|
||||||
|
$this->assertEquals(array('romanb'), $params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user