Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Merged
merged 1 commit into from

4 participants

@vclayton

Patch to address DDC-2113, by surrounding the WHERE clause conditional with parens if there are any filterClauses

@guilhermeblanco guilhermeblanco merged commit 129d6ef into doctrine:master
@beberlei
Owner

why did neither doctrinebot nor travis comment here?

@stof

dunno. Mayb ean issue with the github hooks or the github api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 2, 2012
This page is out of date. Refresh to see the latest.
View
2  lib/Doctrine/ORM/Query/SqlWalker.php
@@ -1700,7 +1700,7 @@ public function walkWhereClause($whereClause)
if (count($filterClauses)) {
if ($condSql) {
- $condSql .= ' AND ';
+ $condSql = '(' . $condSql . ') AND ';
}
$condSql .= implode(' AND ', $filterClauses);
View
16 tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php
@@ -453,6 +453,22 @@ public function testWhereFilter()
$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()
{
Something went wrong with that request. Please try again.