DDC-2934 Added support for function declarations in order by.
This commit is contained in:
parent
54898eca60
commit
ceada41b83
@ -1512,7 +1512,7 @@ Items
|
|||||||
.. code-block:: php
|
.. code-block:: php
|
||||||
|
|
||||||
UpdateItem ::= SingleValuedPathExpression "=" NewValue
|
UpdateItem ::= SingleValuedPathExpression "=" NewValue
|
||||||
OrderByItem ::= (SimpleArithmeticExpression | SingleValuedPathExpression | ScalarExpression | ResultVariable) ["ASC" | "DESC"]
|
OrderByItem ::= (SimpleArithmeticExpression | SingleValuedPathExpression | ScalarExpression | ResultVariable | FunctionDeclaration) ["ASC" | "DESC"]
|
||||||
GroupByItem ::= IdentificationVariable | ResultVariable | SingleValuedPathExpression
|
GroupByItem ::= IdentificationVariable | ResultVariable | SingleValuedPathExpression
|
||||||
NewValue ::= SimpleArithmeticExpression | "NULL"
|
NewValue ::= SimpleArithmeticExpression | "NULL"
|
||||||
|
|
||||||
|
@ -1456,37 +1456,41 @@ class Parser
|
|||||||
/**
|
/**
|
||||||
* OrderByItem ::= (
|
* OrderByItem ::= (
|
||||||
* SimpleArithmeticExpression | SingleValuedPathExpression |
|
* SimpleArithmeticExpression | SingleValuedPathExpression |
|
||||||
* ScalarExpression | ResultVariable
|
* ScalarExpression | ResultVariable | FunctionDeclaration
|
||||||
* ) ["ASC" | "DESC"]
|
* ) ["ASC" | "DESC"]
|
||||||
*
|
*
|
||||||
* @return \Doctrine\ORM\Query\AST\OrderByItem
|
* @return \Doctrine\ORM\Query\AST\OrderByItem
|
||||||
*/
|
*/
|
||||||
public function OrderByItem()
|
public function OrderByItem()
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->lexer->peek(); // lookahead => '.'
|
$this->lexer->peek(); // lookahead => '.'
|
||||||
$this->lexer->peek(); // lookahead => token after '.'
|
$this->lexer->peek(); // lookahead => token after '.'
|
||||||
|
|
||||||
$peek = $this->lexer->peek(); // lookahead => token after the token after the '.'
|
$peek = $this->lexer->peek(); // lookahead => token after the token after the '.'
|
||||||
|
|
||||||
$this->lexer->resetPeek();
|
$this->lexer->resetPeek();
|
||||||
|
|
||||||
$glimpse = $this->lexer->glimpse();
|
$glimpse = $this->lexer->glimpse();
|
||||||
|
|
||||||
switch (true) {
|
switch (true) {
|
||||||
|
case ($this->isFunction($peek)):
|
||||||
|
$expr = $this->FunctionDeclaration();
|
||||||
|
break;
|
||||||
|
|
||||||
case ($this->isMathOperator($peek)):
|
case ($this->isMathOperator($peek)):
|
||||||
$expr = $this->SimpleArithmeticExpression();
|
$expr = $this->SimpleArithmeticExpression();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ($glimpse['type'] === Lexer::T_DOT):
|
case ($glimpse['type'] === Lexer::T_DOT):
|
||||||
$expr = $this->SingleValuedPathExpression();
|
$expr = $this->SingleValuedPathExpression();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ($this->lexer->peek() && $this->isMathOperator($this->peekBeyondClosingParenthesis())):
|
case ($this->lexer->peek() && $this->isMathOperator($this->peekBeyondClosingParenthesis())):
|
||||||
$expr = $this->ScalarExpression();
|
$expr = $this->ScalarExpression();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$expr = $this->ResultVariable();
|
$expr = $this->ResultVariable();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1836,6 +1836,14 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testOrderByClauseSupportsFunction()
|
||||||
|
{
|
||||||
|
$this->assertSqlGeneration(
|
||||||
|
'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY CONCAT(u.username, u.name) ',
|
||||||
|
'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ ORDER BY c0_.username || c0_.name ASC'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group DDC-1719
|
* @group DDC-1719
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user