1
0
mirror of synced 2024-12-14 07:06:04 +03:00

[DDC-2113] Surround WHERE clause with parens if using SQLFilter

This commit is contained in:
Vaughn Clayton 2012-11-01 17:43:18 -04:00
parent 98c5b34f2b
commit ae30ce4596
2 changed files with 17 additions and 1 deletions

View File

@ -1700,7 +1700,7 @@ class SqlWalker implements TreeWalker
if (count($filterClauses)) {
if ($condSql) {
$condSql .= ' AND ';
$condSql = '(' . $condSql . ') AND ';
}
$condSql .= implode(' AND ', $filterClauses);

View File

@ -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()
{