Skip to content

Commit

Permalink
DDC-2827 Added support for AggregateExpressions in NullComparisonExpr…
Browse files Browse the repository at this point in the history
…ession.
  • Loading branch information
guilhermeblanco committed Apr 17, 2014
1 parent ceada41 commit 841bdd5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/en/reference/dql-doctrine-query-language.rst
Expand Up @@ -1647,7 +1647,7 @@ QUANTIFIED/BETWEEN/COMPARISON/LIKE/NULL/EXISTS
InstanceOfExpression ::= IdentificationVariable ["NOT"] "INSTANCE" ["OF"] (InstanceOfParameter | "(" InstanceOfParameter {"," InstanceOfParameter}* ")")
InstanceOfParameter ::= AbstractSchemaName | InputParameter
LikeExpression ::= StringExpression ["NOT"] "LIKE" StringPrimary ["ESCAPE" char]
NullComparisonExpression ::= (InputParameter | NullIfExpression | CoalesceExpression | SingleValuedPathExpression | ResultVariable) "IS" ["NOT"] "NULL"
NullComparisonExpression ::= (InputParameter | NullIfExpression | CoalesceExpression | AggregateExpression | FunctionDeclaration | IdentificationVariable | SingleValuedPathExpression | ResultVariable) "IS" ["NOT"] "NULL"
ExistsExpression ::= ["NOT"] "EXISTS" "(" Subselect ")"
ComparisonOperator ::= "=" | "<" | "<=" | "<>" | ">" | ">=" | "!="
Expand Down
6 changes: 5 additions & 1 deletion lib/Doctrine/ORM/Query/Parser.php
Expand Up @@ -3131,7 +3131,7 @@ public function LikeExpression()
}

/**
* NullComparisonExpression ::= (InputParameter | NullIfExpression | CoalesceExpression | SingleValuedPathExpression | ResultVariable) "IS" ["NOT"] "NULL"
* NullComparisonExpression ::= (InputParameter | NullIfExpression | CoalesceExpression | AggregateExpression | FunctionDeclaration | IdentificationVariable | SingleValuedPathExpression | ResultVariable) "IS" ["NOT"] "NULL"
*
* @return \Doctrine\ORM\Query\AST\NullComparisonExpression
*/
Expand All @@ -3151,6 +3151,10 @@ public function NullComparisonExpression()
case $this->lexer->isNextToken(Lexer::T_COALESCE):
$expr = $this->CoalesceExpression();
break;

case $this->isAggregateFunction($this->lexer->lookahead['type']):
$expr = $this->AggregateExpression();
break;

case $this->isFunction():
$expr = $this->FunctionDeclaration();
Expand Down
5 changes: 5 additions & 0 deletions tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php
Expand Up @@ -2062,6 +2062,11 @@ public function testHavingSupportIsNullExpression()
'SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u HAVING u.username IS NULL',
'SELECT c0_.name AS name_0 FROM cms_users c0_ HAVING c0_.username IS NULL'
);

$this->assertSqlGeneration(
'SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u HAVING MAX(u.name) IS NULL',
'SELECT c0_.name AS name_0 FROM cms_users c0_ HAVING MAX(c0_.name) IS NULL'
);
}

/**
Expand Down

0 comments on commit 841bdd5

Please sign in to comment.