Merge branch 'fix/#5599-having-regression-fix-2.5' into 2.5
Backport #5599 into 2.5
This commit is contained in:
commit
dfbc6bbea3
@ -2264,7 +2264,9 @@ class SqlWalker implements TreeWalker
|
|||||||
public function walkArithmeticFactor($factor)
|
public function walkArithmeticFactor($factor)
|
||||||
{
|
{
|
||||||
if (is_string($factor)) {
|
if (is_string($factor)) {
|
||||||
return $factor;
|
return (isset($this->queryComponents[$factor]))
|
||||||
|
? $this->walkResultVariable($this->queryComponents[$factor]['token']['value'])
|
||||||
|
: $factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Phase 2 AST optimization: Skip processing of ArithmeticFactor
|
// Phase 2 AST optimization: Skip processing of ArithmeticFactor
|
||||||
|
@ -2242,6 +2242,27 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
'SELECT COUNT(c0_.name) AS sclr_0 FROM cms_users c0_ HAVING sclr_0 IS NULL'
|
'SELECT COUNT(c0_.name) AS sclr_0 FROM cms_users c0_ HAVING sclr_0 IS NULL'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GitHub issue #4764: https://github.com/doctrine/doctrine2/issues/4764
|
||||||
|
* @group DDC-3907
|
||||||
|
* @dataProvider mathematicOperatorsProvider
|
||||||
|
*/
|
||||||
|
public function testHavingRegressionUsingVariableWithMathOperatorsExpression($operator)
|
||||||
|
{
|
||||||
|
$this->assertSqlGeneration(
|
||||||
|
'SELECT COUNT(u.name) AS countName FROM Doctrine\Tests\Models\CMS\CmsUser u HAVING 1 ' . $operator . ' countName > 0',
|
||||||
|
'SELECT COUNT(c0_.name) AS sclr_0 FROM cms_users c0_ HAVING 1 ' . $operator . ' sclr_0 > 0'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function mathematicOperatorsProvider()
|
||||||
|
{
|
||||||
|
return [['+'], ['-'], ['*'], ['/']];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyAbsFunction extends \Doctrine\ORM\Query\AST\Functions\FunctionNode
|
class MyAbsFunction extends \Doctrine\ORM\Query\AST\Functions\FunctionNode
|
||||||
|
Loading…
x
Reference in New Issue
Block a user