Merge branch 'DDC-1079'
This commit is contained in:
commit
5022b04ff9
@ -1644,7 +1644,7 @@ class Parser
|
|||||||
return $this->StateFieldPathExpression();
|
return $this->StateFieldPathExpression();
|
||||||
} else if ($lookahead == Lexer::T_INTEGER || $lookahead == Lexer::T_FLOAT) {
|
} else if ($lookahead == Lexer::T_INTEGER || $lookahead == Lexer::T_FLOAT) {
|
||||||
return $this->SimpleArithmeticExpression();
|
return $this->SimpleArithmeticExpression();
|
||||||
} else if ($this->_isFunction()) {
|
} else if ($this->_isFunction() || $this->_isAggregateFunction($this->_lexer->lookahead['type'])) {
|
||||||
// We may be in an ArithmeticExpression (find the matching ")" and inspect for Math operator)
|
// We may be in an ArithmeticExpression (find the matching ")" and inspect for Math operator)
|
||||||
$this->_lexer->peek(); // "("
|
$this->_lexer->peek(); // "("
|
||||||
$peek = $this->_peekBeyondClosingParenthesis();
|
$peek = $this->_peekBeyondClosingParenthesis();
|
||||||
@ -1653,7 +1653,11 @@ class Parser
|
|||||||
return $this->SimpleArithmeticExpression();
|
return $this->SimpleArithmeticExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->_isAggregateFunction($this->_lexer->lookahead['type'])) {
|
||||||
|
return $this->AggregateExpression();
|
||||||
|
} else {
|
||||||
return $this->FunctionDeclaration();
|
return $this->FunctionDeclaration();
|
||||||
|
}
|
||||||
} else if ($lookahead == Lexer::T_STRING) {
|
} else if ($lookahead == Lexer::T_STRING) {
|
||||||
return $this->StringPrimary();
|
return $this->StringPrimary();
|
||||||
} else if ($lookahead == Lexer::T_INPUT_PARAMETER) {
|
} else if ($lookahead == Lexer::T_INPUT_PARAMETER) {
|
||||||
@ -1797,15 +1801,8 @@ class Parser
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->_lexer->peek();
|
$this->_lexer->peek();
|
||||||
$beyond = $this->_peekBeyondClosingParenthesis();
|
|
||||||
|
|
||||||
if ($this->_isMathOperator($beyond)) {
|
|
||||||
$expression = $this->ScalarExpression();
|
$expression = $this->ScalarExpression();
|
||||||
} else if ($this->_isAggregateFunction($this->_lexer->lookahead['type'])) {
|
|
||||||
$expression = $this->AggregateExpression();
|
|
||||||
} else {
|
|
||||||
$expression = $this->FunctionDeclaration();
|
|
||||||
}
|
|
||||||
|
|
||||||
$expr = new AST\SimpleSelectExpression($expression);
|
$expr = new AST\SimpleSelectExpression($expression);
|
||||||
|
|
||||||
|
@ -251,6 +251,15 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
$this->assertValidDQL("SELECT (SELECT (SUM(u.id) / COUNT(u.id)) FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'");
|
$this->assertValidDQL("SELECT (SELECT (SUM(u.id) / COUNT(u.id)) FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group DDC-1079
|
||||||
|
*/
|
||||||
|
public function testSelectLiteralInSubselect()
|
||||||
|
{
|
||||||
|
$this->assertValidDQL('SELECT (SELECT 1 FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u');
|
||||||
|
$this->assertValidDQL('SELECT (SELECT 0 FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u');
|
||||||
|
}
|
||||||
|
|
||||||
public function testDuplicateAliasInSubselectPart()
|
public function testDuplicateAliasInSubselectPart()
|
||||||
{
|
{
|
||||||
$this->assertInvalidDQL("SELECT (SELECT SUM(u.id) / COUNT(u.id) AS foo FROM Doctrine\Tests\Models\CMS\CmsUser u2) foo FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'");
|
$this->assertInvalidDQL("SELECT (SELECT SUM(u.id) / COUNT(u.id) AS foo FROM Doctrine\Tests\Models\CMS\CmsUser u2) foo FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'");
|
||||||
|
Loading…
Reference in New Issue
Block a user