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

Merge branch 'master' of github.com:doctrine/doctrine2

This commit is contained in:
Benjamin Eberlei 2011-07-03 12:07:40 +02:00
commit 73f908f25c
4 changed files with 31 additions and 5 deletions

View File

@ -43,11 +43,26 @@ class Composite extends Base
$components = array(); $components = array();
foreach ($this->_parts as $part) { foreach ($this->_parts as $part) {
$components[] = (is_object($part) && $part instanceof self && $part->count() > 1) $components[] = $this->processQueryPart($part);
? $this->_preSeparator . ((string) $part) . $this->_postSeparator
: ((string) $part);
} }
return implode($this->_separator, $components); 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;
}
} }

View File

@ -36,7 +36,7 @@ class Version
/** /**
* Current Doctrine Version * Current Doctrine Version
*/ */
const VERSION = '2.1.0-DEV'; const VERSION = '2.1.0RC4-DEV';
/** /**
* Compares a Doctrine version with the current one. * Compares a Doctrine version with the current one.

@ -1 +1 @@
Subproject commit 9a4add6713069fddc36b79484909c010b6c110c1 Subproject commit 74a2c924cd08b30785877808b1fb519b4b2e60b1

View File

@ -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'); $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() public function testAndWhere()
{ {