1
0
mirror of synced 2025-01-22 08:11:40 +03:00

Fixes a Fatal Error when using a subexpression in parenthesis

When some dql contains a subselect with expression in parenthesis, the
expression of the $simpleSelectExpression parameter given to
walkSimpleSelectExpression is an instance of AST\ParenthesisExpression.
Before this commit, this case defaulted to
$this->walkEntityIdentificationVariable($expr) where $expr is supposed
to be a string. A fatal error was then yielded.
This commit is contained in:
Vincent BOURDEIX 2013-10-14 15:04:52 +02:00
parent 0d58e82b76
commit 5506d7adce
2 changed files with 11 additions and 0 deletions

View File

@ -1581,6 +1581,10 @@ class SqlWalker implements TreeWalker
$sql .= $expr->dispatch($this) . ' AS ' . $columnAlias; $sql .= $expr->dispatch($this) . ' AS ' . $columnAlias;
break; break;
case ($expr instanceof AST\ParenthesisExpression):
$sql .= $this->walkParenthesisExpression($expr);
break;
default: // IdentificationVariable default: // IdentificationVariable
$sql .= $this->walkEntityIdentificationVariable($expr); $sql .= $this->walkEntityIdentificationVariable($expr);
break; break;

View File

@ -1641,6 +1641,13 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
); );
} }
public function testSupportsParenthesisExpressionInSubSelect() {
$this->assertSqlGeneration(
'SELECT u.id, (SELECT (1000*SUM(subU.id)/SUM(subU.id)) FROM Doctrine\Tests\Models\CMS\CmsUser subU where subU.id = u.id) AS subSelect FROM Doctrine\Tests\Models\CMS\CmsUser u',
'SELECT c0_.id AS id0, (SELECT (1000 * SUM(c1_.id) / SUM(c1_.id)) FROM cms_users c1_ WHERE c1_.id = c0_.id) AS sclr1 FROM cms_users c0_'
);
}
/** /**
* @group DDC-1557 * @group DDC-1557
*/ */