Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated parser to support aggegrate functions in null comparisons #864

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/Doctrine/ORM/Query/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -549,12 +549,14 @@ private function isFunction()
/**
* Checks whether the given token type indicates an aggregate function.
*
* @param int $tokenType
* @param int|null $tokenType Token type to be checked, or NULL to check lookahead token.
*
* @return boolean TRUE if the token type is an aggregate function, FALSE otherwise.
*/
private function isAggregateFunction($tokenType)
private function isAggregateFunction($tokenType = null)
{
if(!isset($tokenType))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use null === instead of !isset, and please add the curly braces

$tokenType = $this->lexer->lookahead['type'];
return in_array($tokenType, array(Lexer::T_AVG, Lexer::T_MIN, Lexer::T_MAX, Lexer::T_SUM, Lexer::T_COUNT));
}

Expand Down Expand Up @@ -3142,6 +3144,10 @@ public function NullComparisonExpression()
$expr = $this->CoalesceExpression();
break;

case $this->isAggregateFunction():
$expr = $this->SimpleArithmeticExpression();
break;

case $this->isFunction():
$expr = $this->FunctionDeclaration();
break;
Expand Down