Skip to content

Commit

Permalink
[DDC-593] Fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
romanb committed May 16, 2010
1 parent 3b01277 commit 3045507
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Query/SqlWalker.php
Expand Up @@ -1620,7 +1620,7 @@ public function walkArithmeticExpression($arithmeticExpr)
{
return ($arithmeticExpr->isSimpleArithmeticExpression())
? $this->walkSimpleArithmeticExpression($arithmeticExpr->simpleArithmeticExpression)
: $this->walkSubselect($arithmeticExpr->subselect);
: '(' . $this->walkSubselect($arithmeticExpr->subselect) . ')';
}

/**
Expand Down
11 changes: 11 additions & 0 deletions tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php
Expand Up @@ -325,6 +325,17 @@ public function testSupportsExistsExpressionInWherePartWithCorrelatedSubquery()
);
}

/**
* @group DDC-593
*/
public function testSubqueriesInComparisonExpression()
{
$this->assertSqlGeneration(
'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (u.id >= (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = :name)) AND (u.id <= (SELECT u3.id FROM Doctrine\Tests\Models\CMS\CmsUser u3 WHERE u3.name = :name))',
'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE (c0_.id >= (SELECT c1_.id FROM cms_users c1_ WHERE c1_.name = ?)) AND (c0_.id <= (SELECT c2_.id FROM cms_users c2_ WHERE c2_.name = ?))'
);
}

public function testSupportsMemberOfExpression()
{
// "Get all users who have $phone as a phonenumber." (*cough* doesnt really make sense...)
Expand Down

0 comments on commit 3045507

Please sign in to comment.