Commit bb94f6ea authored by guilhermeblanco's avatar guilhermeblanco

[2.0] Fixed support to ResultVariable usage in ArithmeticExpression.

parent 0fde94dd
......@@ -2129,7 +2129,7 @@ class Parser
/**
* ArithmeticPrimary ::= SingleValuedPathExpression | Literal | "(" SimpleArithmeticExpression ")"
* | FunctionsReturningNumerics | AggregateExpression | FunctionsReturningStrings
* | FunctionsReturningDatetime | IdentificationVariable
* | FunctionsReturningDatetime | ResultVariable
*/
public function ArithmeticPrimary()
{
......@@ -2154,7 +2154,7 @@ class Parser
return $this->SingleValuedPathExpression();
}
return $this->IdentificationVariable();
return $this->ResultVariable();
case Lexer::T_INPUT_PARAMETER:
return $this->InputParameter();
......
......@@ -1639,6 +1639,10 @@ class SqlWalker implements TreeWalker
$sql .= '(' . $this->walkSimpleArithmeticExpression($primary) . ')';
} else if ($primary instanceof AST\Node) {
$sql .= $primary->dispatch($this);
} else if (is_string($primary)) {
$columnName = $this->_queryComponents[$primary]['token']['value'];
$sql .= $this->_scalarResultAliasMap[$columnName];
}
return $sql;
......
......@@ -527,6 +527,14 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
);
}
public function testSupportResultVariableInWherePart()
{
$this->assertSqlGeneration(
"SELECT p.phonenumber, COUNT(p.user) AS total FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE total > 0 GROUP BY p.user",
"SELECT c0_.phonenumber AS phonenumber0, COUNT(c0_.user_id) AS sclr1 FROM cms_phonenumbers c0_ WHERE sclr1 > 0 GROUP BY c0_.user_id"
);
}
public function testSingleValuedAssociationNullCheckOnOwningSide()
{
$this->assertSqlGeneration(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment