[DDC-2113] Surround WHERE clause with parens if using SQLFilter
This commit is contained in:
parent
98c5b34f2b
commit
ae30ce4596
2 changed files with 17 additions and 1 deletions
|
@ -1700,7 +1700,7 @@ class SqlWalker implements TreeWalker
|
||||||
|
|
||||||
if (count($filterClauses)) {
|
if (count($filterClauses)) {
|
||||||
if ($condSql) {
|
if ($condSql) {
|
||||||
$condSql .= ' AND ';
|
$condSql = '(' . $condSql . ') AND ';
|
||||||
}
|
}
|
||||||
|
|
||||||
$condSql .= implode(' AND ', $filterClauses);
|
$condSql .= implode(' AND ', $filterClauses);
|
||||||
|
|
|
@ -453,6 +453,22 @@ class SQLFilterTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||||
$this->assertEquals(1, count($query->getResult()));
|
$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()
|
private function loadLazyFixtureData()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue