forked from doctrine/orm
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Query\Expr::_quoteLiteral properly quotes numeric strings
- Loading branch information
Showing
2 changed files
with
31 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ | |
require_once __DIR__ . '/../../TestInit.php'; | ||
|
||
/** | ||
* Test case for the DQL Expr class used for generating DQL snippets through | ||
* Test case for the DQL Expr class used for generating DQL snippets through | ||
* a programmatic interface | ||
* | ||
* @author Jonathan H. Wage <[email protected]> | ||
|
@@ -75,51 +75,51 @@ public function testExistsExpr() | |
{ | ||
$qb = $this->_em->createQueryBuilder(); | ||
$qb->select('u')->from('User', 'u')->where('u.name = ?1'); | ||
|
||
$this->assertEquals('EXISTS(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->_expr->exists($qb)); | ||
} | ||
|
||
public function testAllExpr() | ||
{ | ||
$qb = $this->_em->createQueryBuilder(); | ||
$qb->select('u')->from('User', 'u')->where('u.name = ?1'); | ||
|
||
$this->assertEquals('ALL(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->_expr->all($qb)); | ||
} | ||
|
||
public function testSomeExpr() | ||
{ | ||
$qb = $this->_em->createQueryBuilder(); | ||
$qb->select('u')->from('User', 'u')->where('u.name = ?1'); | ||
|
||
$this->assertEquals('SOME(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->_expr->some($qb)); | ||
} | ||
|
||
public function testAnyExpr() | ||
{ | ||
$qb = $this->_em->createQueryBuilder(); | ||
$qb->select('u')->from('User', 'u')->where('u.name = ?1'); | ||
|
||
$this->assertEquals('ANY(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->_expr->any($qb)); | ||
} | ||
|
||
public function testNotExpr() | ||
{ | ||
$qb = $this->_em->createQueryBuilder(); | ||
$qb->select('u')->from('User', 'u')->where('u.name = ?1'); | ||
|
||
$this->assertEquals('NOT(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->_expr->not($qb)); | ||
} | ||
|
||
public function testAndExpr() | ||
{ | ||
$this->assertEquals('(1 = 1) AND (2 = 2)', (string) $this->_expr->andx((string) $this->_expr->eq(1, 1), (string) $this->_expr->eq(2, 2))); | ||
} | ||
|
||
public function testIntelligentParenthesisPreventionAndExpr() | ||
{ | ||
$this->assertEquals( | ||
'(1 = 1) AND (2 = 2)', | ||
'(1 = 1) AND (2 = 2)', | ||
(string) $this->_expr->andx($this->_expr->orx($this->_expr->andx($this->_expr->eq(1, 1))), (string) $this->_expr->eq(2, 2)) | ||
); | ||
} | ||
|
@@ -153,7 +153,7 @@ public function testQuotientExpr() | |
{ | ||
$this->assertEquals('10 / 2', (string) $this->_expr->quot(10, 2)); | ||
} | ||
|
||
public function testScopeInArithmeticExpr() | ||
{ | ||
$this->assertEquals('(100 - 20) / 2', (string) $this->_expr->quot($this->_expr->diff(100, 20), 2)); | ||
|
@@ -220,6 +220,15 @@ public function testNumericLiteralExpr() | |
$this->assertEquals(5, (string) $this->_expr->literal(5)); | ||
} | ||
|
||
/** | ||
* @group regression | ||
* @group DDC-610 | ||
*/ | ||
public function testLiteralExprProperlyQuotesStrings() | ||
{ | ||
$this->assertEquals("'00010001'", (string) $this->_expr->literal('00010001')); | ||
} | ||
|
||
public function testGreaterThanOrEqualToExpr() | ||
{ | ||
$this->assertEquals('5 >= 2', (string) $this->_expr->gte(5, 2)); | ||
|
@@ -266,7 +275,7 @@ public function testOrxExpr() | |
|
||
$this->assertEquals('(1 = 1) OR (1 < 5)', (string) $orExpr); | ||
} | ||
|
||
public function testOrderByCountExpr() | ||
{ | ||
$orderExpr = $this->_expr->desc('u.username'); | ||
|