[DDC-2113] Surround WHERE clause with parens if using SQLFilter
This commit is contained in:
parent
98c5b34f2b
commit
ae30ce4596
@ -1700,7 +1700,7 @@ class SqlWalker implements TreeWalker
|
||||
|
||||
if (count($filterClauses)) {
|
||||
if ($condSql) {
|
||||
$condSql .= ' AND ';
|
||||
$condSql = '(' . $condSql . ') AND ';
|
||||
}
|
||||
|
||||
$condSql .= implode(' AND ', $filterClauses);
|
||||
|
@ -453,6 +453,22 @@ class SQLFilterTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->assertEquals(1, count($query->getResult()));
|
||||
}
|
||||
|
||||
public function testWhereOrFilter()
|
||||
{
|
||||
$this->loadFixtureData();
|
||||
$query = $this->_em->createQuery('select ug from Doctrine\Tests\Models\CMS\CmsGroup ug WHERE 1=1 OR 1=1');
|
||||
|
||||
// We get two users before enabling the filter
|
||||
$this->assertEquals(2, count($query->getResult()));
|
||||
|
||||
$conf = $this->_em->getConfiguration();
|
||||
$conf->addFilter("group_prefix", "\Doctrine\Tests\ORM\Functional\CMSGroupPrefixFilter");
|
||||
$this->_em->getFilters()->enable("group_prefix")->setParameter("prefix", "bar_%", DBALType::STRING);
|
||||
|
||||
// We get one user after enabling the filter
|
||||
$this->assertEquals(1, count($query->getResult()));
|
||||
}
|
||||
|
||||
|
||||
private function loadLazyFixtureData()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user