1
0
mirror of synced 2024-12-14 07:06:04 +03:00

fix DDC-1557

This commit is contained in:
Fabio B. Silva 2011-12-29 14:30:29 -02:00
parent ff4ed93707
commit 4cc61bf2ee
2 changed files with 31 additions and 0 deletions

View File

@ -2004,6 +2004,18 @@ class Parser
return new AST\SimpleSelectExpression($expression);
case ($this->_isFunction()):
// SUM(u.id) + COUNT(u.id)
if ($this->_isMathOperator($this->_peekBeyondClosingParenthesis())) {
return new AST\SimpleSelectExpression($this->ScalarExpression());
}
// COUNT(u.id)
if ($this->_isAggregateFunction($this->_lexer->lookahead['type'])) {
return new AST\SimpleSelectExpression($this->AggregateExpression());
}
// IDENTITY(u)
return new AST\SimpleSelectExpression($this->FunctionDeclaration());
default:
// Do nothing
}

View File

@ -1434,6 +1434,25 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
);
}
/**
* @group DDC-1557
*/
public function testSupportsSubSqlFunction()
{
$this->assertSqlGeneration(
'SELECT u1 FROM Doctrine\Tests\Models\CMS\CmsUser u1 WHERE u1.name IN ( SELECT TRIM(u2.name) FROM Doctrine\Tests\Models\CMS\CmsUser u2 )',
'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE c0_.name IN (SELECT TRIM(c1_.name) AS sclr4 FROM cms_users c1_)'
);
$this->assertSqlGeneration(
'SELECT u1 FROM Doctrine\Tests\Models\CMS\CmsUser u1 WHERE u1.name IN ( SELECT TRIM(u2.name) FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE LOWER(u2.name) LIKE \'%fabio%\')',
'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE c0_.name IN (SELECT TRIM(c1_.name) AS sclr4 FROM cms_users c1_ WHERE LOWER(c1_.name) LIKE \'%fabio%\')'
);
$this->assertSqlGeneration(
'SELECT u1 FROM Doctrine\Tests\Models\CMS\CmsUser u1 WHERE u1.email IN ( SELECT TRIM(IDENTITY(u2.email)) FROM Doctrine\Tests\Models\CMS\CmsUser u2 )',
'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE c0_.email_id IN (SELECT TRIM(c1_.email_id) AS sclr4 FROM cms_users c1_)'
);
}
public function testCustomTypeValueSql()
{
if (DBALType::hasType('negative_to_positive')) {