remove case expressions and functions support
This commit is contained in:
parent
797c9cf70e
commit
e46275e80d
@ -1334,8 +1334,8 @@ class Parser
|
||||
|
||||
/**
|
||||
* OrderByItem ::= (
|
||||
* SimpleArithmeticExpression | SingleValuedPathExpression | CaseExpression |
|
||||
* ScalarExpression | AggregateExpression | FunctionDeclaration | ResultVariable
|
||||
* SimpleArithmeticExpression | SingleValuedPathExpression |
|
||||
* ScalarExpression | ResultVariable
|
||||
* ) ["ASC" | "DESC"]
|
||||
*
|
||||
* @return \Doctrine\ORM\Query\AST\OrderByItem
|
||||
@ -1359,34 +1359,13 @@ class Parser
|
||||
$expr = $this->SingleValuedPathExpression();
|
||||
|
||||
break;
|
||||
case ($this->_lexer->peek() && $this->_isMathOperator($this->_peekBeyondClosingParenthesis())):
|
||||
$expr = $this->ScalarExpression();
|
||||
|
||||
case ($this->_lexer->lookahead['type'] === Lexer::T_CASE):
|
||||
case ($this->_lexer->lookahead['type'] === Lexer::T_COALESCE):
|
||||
case ($this->_lexer->lookahead['type'] === Lexer::T_NULLIF):
|
||||
// Since NULLIF and COALESCE can be identified as a function,
|
||||
// we need to check if before check for FunctionDeclaration
|
||||
$expr = $this->CaseExpression();
|
||||
break;
|
||||
|
||||
case ($this->_isFunction()):
|
||||
$this->_lexer->peek(); // "("
|
||||
|
||||
// SUM(u.id) + COUNT(u.id)
|
||||
if ($this->_isMathOperator($this->_peekBeyondClosingParenthesis())) {
|
||||
$expr = $this->ScalarExpression();
|
||||
break;
|
||||
}
|
||||
// COUNT(u.id)
|
||||
if ($this->_isAggregateFunction($this->_lexer->lookahead['type'])) {
|
||||
$expr = $this->AggregateExpression();
|
||||
break;
|
||||
}
|
||||
// IDENTITY(u)
|
||||
$expr = $this->FunctionDeclaration();
|
||||
break;
|
||||
|
||||
default:
|
||||
$expr = $this->ResultVariable();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1572,33 +1572,6 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-775
|
||||
*/
|
||||
public function testOrderByClauseSupportsFunctions()
|
||||
{
|
||||
$this->assertSqlGeneration(
|
||||
'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY TRIM(u.name)',
|
||||
'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ ORDER BY TRIM(c0_.name) ASC'
|
||||
);
|
||||
$this->assertSqlGeneration(
|
||||
'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY IDENTITY(u.email)',
|
||||
'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ ORDER BY c0_.email_id ASC'
|
||||
);
|
||||
$this->assertSqlGeneration(
|
||||
'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY TRIM(IDENTITY(u.email))',
|
||||
'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ ORDER BY TRIM(c0_.email_id) ASC'
|
||||
);
|
||||
$this->assertSqlGeneration(
|
||||
'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY SUM(u.id)',
|
||||
'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ ORDER BY SUM(c0_.id) ASC'
|
||||
);
|
||||
$this->assertSqlGeneration(
|
||||
'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY SUM(u.id) + COUNT(u.email)',
|
||||
'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ ORDER BY SUM(c0_.id) + COUNT(c0_.email_id) ASC'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-775
|
||||
*/
|
||||
@ -1616,30 +1589,8 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
|
||||
'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY ((u.id + 5000) * u.id + 3) ',
|
||||
'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ ORDER BY (c0_.id + 5000) * c0_.id + 3 ASC'
|
||||
);
|
||||
$this->assertSqlGeneration(
|
||||
'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY ((u.id + 5000) * SUM(u.id) + 3) ',
|
||||
'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ ORDER BY (c0_.id + 5000) * SUM(c0_.id) + 3 ASC'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-775
|
||||
*/
|
||||
public function testOrderByClauseSupportsNullIfAndCoalesce()
|
||||
{
|
||||
$this->assertSqlGeneration(
|
||||
'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY NULLIF(u.name, u.username)',
|
||||
'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ ORDER BY NULLIF(c0_.name, c0_.username) ASC'
|
||||
);
|
||||
$this->assertSqlGeneration(
|
||||
'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY COALESCE(NULLIF(u.name, u.username), u.id)',
|
||||
'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ ORDER BY COALESCE(NULLIF(c0_.name, c0_.username), c0_.id) ASC'
|
||||
);
|
||||
$this->assertSqlGeneration(
|
||||
'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY CASE u.id WHEN 1 THEN 1 ELSE 0 END',
|
||||
'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ ORDER BY CASE c0_.id WHEN 1 THEN 1 ELSE 0 END ASC'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user