From cbe14a694a3fc922d356d8c1eb2c70c372ba012c Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sat, 2 Jul 2011 20:28:04 +0000 Subject: [PATCH 1/4] Update Common dependency to 2.1 RC3 --- lib/vendor/doctrine-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vendor/doctrine-common b/lib/vendor/doctrine-common index 9a4add671..74a2c924c 160000 --- a/lib/vendor/doctrine-common +++ b/lib/vendor/doctrine-common @@ -1 +1 @@ -Subproject commit 9a4add6713069fddc36b79484909c010b6c110c1 +Subproject commit 74a2c924cd08b30785877808b1fb519b4b2e60b1 From e4f2a5627749dd30958a1e7f10c39839c45e1772 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sat, 2 Jul 2011 20:28:37 +0000 Subject: [PATCH 2/4] Release 2.1.0RC3 --- lib/Doctrine/ORM/Version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Version.php b/lib/Doctrine/ORM/Version.php index e459dceb6..d6d32a10b 100644 --- a/lib/Doctrine/ORM/Version.php +++ b/lib/Doctrine/ORM/Version.php @@ -36,7 +36,7 @@ class Version /** * Current Doctrine Version */ - const VERSION = '2.1.0-DEV'; + const VERSION = '2.1.0RC3'; /** * Compares a Doctrine version with the current one. From ffca455788d251529994e9268a67a9822ed6d05b Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sat, 2 Jul 2011 20:29:02 +0000 Subject: [PATCH 3/4] Bump Dev Version to 2.1.0RC4-DEV --- lib/Doctrine/ORM/Version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Version.php b/lib/Doctrine/ORM/Version.php index d6d32a10b..5e811edd0 100644 --- a/lib/Doctrine/ORM/Version.php +++ b/lib/Doctrine/ORM/Version.php @@ -36,7 +36,7 @@ class Version /** * Current Doctrine Version */ - const VERSION = '2.1.0RC3'; + const VERSION = '2.1.0RC4-DEV'; /** * Compares a Doctrine version with the current one. From 550fcbc17fc9d927edf34bd0e5f9efc3b68ce344 Mon Sep 17 00:00:00 2001 From: Guilherme Blanco Date: Sun, 3 Jul 2011 01:48:18 -0300 Subject: [PATCH 4/4] [DDC-1237] Fixed issue with QueryBuilder where user may have includes nested complex expression in a string format while consuming a composite expression (AND or OR). --- lib/Doctrine/ORM/Query/Expr/Composite.php | 21 ++++++++++++++++--- tests/Doctrine/Tests/ORM/QueryBuilderTest.php | 11 ++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/ORM/Query/Expr/Composite.php b/lib/Doctrine/ORM/Query/Expr/Composite.php index 97c15e64b..0d606a9b0 100644 --- a/lib/Doctrine/ORM/Query/Expr/Composite.php +++ b/lib/Doctrine/ORM/Query/Expr/Composite.php @@ -43,11 +43,26 @@ class Composite extends Base $components = array(); foreach ($this->_parts as $part) { - $components[] = (is_object($part) && $part instanceof self && $part->count() > 1) - ? $this->_preSeparator . ((string) $part) . $this->_postSeparator - : ((string) $part); + $components[] = $this->processQueryPart($part); } return implode($this->_separator, $components); } + + + private function processQueryPart($part) + { + $queryPart = (string) $part; + + if (is_object($part) && $part instanceof self && $part->count() > 1) { + return $this->_preSeparator . $queryPart . $this->_postSeparator; + } + + // Fixes DDC-1237: User may have added a where item containing nested expression (with "OR" or "AND") + if (mb_stripos($queryPart, ' OR ') !== false || mb_stripos($queryPart, ' AND ') !== false) { + return $this->_preSeparator . $queryPart . $this->_postSeparator; + } + + return $queryPart; + } } \ No newline at end of file diff --git a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php index 57eb82946..2b352bdce 100644 --- a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php @@ -197,6 +197,17 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid'); } + + public function testComplexAndWhere() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where('u.id = :uid OR u.id = :uid2 OR u.id = :uid3') + ->andWhere('u.name = :name'); + + $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (u.id = :uid OR u.id = :uid2 OR u.id = :uid3) AND u.name = :name'); + } public function testAndWhere() {