Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.0-BETA2
-
Fix Version/s: 2.0-BETA4
-
Component/s: None
-
Security Level: All
-
Labels:None
Description
It seems complex mathematical expressions are handled differently in DQL Subselects then in normal Selects:
public function testSelectCorrelatedSubqueryComplexMathematicalExpression() { $this->assertSqlGeneration( 'SELECT (SELECT (count(p.phonenumber)+5)*10 FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p JOIN p.user ui WHERE ui.id = u.id) AS c FROM Doctrine\Tests\Models\CMS\CmsUser u', 'SELECT (SELECT (count(c0_.phonenumber)+5)*10 AS dctrn__1 FROM cms_phonenumbers c0_ INNER JOIN cms_users c1_ ON c0_.user_id = c1_.id WHERE c1_.id = c2_.id) AS sclr0 FROM cms_users c2_' ); } public function testSelectComplexMathematicalExpression() { $this->assertSqlGeneration( 'SELECT (count(p.phonenumber)+5)*10 FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p JOIN p.user ui WHERE ui.id = ?1', 'SELECT (count(c0_.phonenumber) + 5) * 10 AS sclr0 FROM cms_phonenumbers c0_ INNER JOIN cms_users c1_ ON c0_.user_id = c1_.id WHERE c1_.id = ?' ); }
Here the first test fails and the second passes. The second has the nested SQL running alone. The failure message is:
1) Doctrine\Tests\ORM\Query\SelectSqlGenerationTest::testSelectCorrelatedSubqueryComplexMathematicalExpression
[Syntax Error] line 0, col 15: Error: Expected One of: MAX, MIN, AVG, SUM, COUNT, got '('
/home/benny/code/php/wsnetbeans/doctrine2/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php:31
/home/benny/code/php/wsnetbeans/doctrine2/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php:709
The problem seems to be in SelectExpression(). Functions are only detected in isolation, i.e. everything after the first function is ignored.