From d27733f6908e04f8d9e66326072e0bbd7017e246 Mon Sep 17 00:00:00 2001 From: "Jonathan H. Wage" Date: Wed, 16 Jun 2010 11:55:22 -0400 Subject: [PATCH] [DDC-613] Fixing issue with using function expressions in select not being allowed --- lib/Doctrine/ORM/Query/Expr/Select.php | 3 +++ tests/Doctrine/Tests/ORM/QueryBuilderTest.php | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/Doctrine/ORM/Query/Expr/Select.php b/lib/Doctrine/ORM/Query/Expr/Select.php index fb049916f..a310a0c7b 100644 --- a/lib/Doctrine/ORM/Query/Expr/Select.php +++ b/lib/Doctrine/ORM/Query/Expr/Select.php @@ -36,4 +36,7 @@ class Select extends Base { protected $_preSeparator = ''; protected $_postSeparator = ''; + protected $_allowedClasses = array( + 'Doctrine\ORM\Query\Expr\Func' + ); } \ No newline at end of file diff --git a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php index 468e0e20c..e2430e8cc 100644 --- a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php @@ -516,4 +516,13 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase $this->assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState()); } + + public function testSelectWithFuncExpression() + { + $qb = $this->_em->createQueryBuilder(); + $expr = $qb->expr(); + $qb->select($expr->count('e.id')); + + $this->assertValidQueryBuilder($qb, 'SELECT COUNT(e.id)'); + } } \ No newline at end of file