Skip to content
Browse files

Merge branch 'DDC-1211'

  • Loading branch information...
2 parents 1c2ade6 + c7c4300 commit fff0204e6d799018d98103a4fec435ec1d54b745 @beberlei beberlei committed Jun 19, 2011
Showing with 29 additions and 1 deletion.
  1. +1 −1 lib/Doctrine/ORM/Query/Expr/Base.php
  2. +28 −0 tests/Doctrine/Tests/ORM/QueryBuilderTest.php
View
2 lib/Doctrine/ORM/Query/Expr/Base.php
@@ -55,7 +55,7 @@ public function addMultiple($args = array())
public function add($arg)
{
- if ( ! empty($arg) || ($arg instanceof self && $arg->count() > 0)) {
+ if ( $arg !== null || ($arg instanceof self && $arg->count() > 0)) {
// If we decide to keep Expr\Base instances, we can use this check
if ( ! is_string($arg)) {
$class = get_class($arg);
View
28 tests/Doctrine/Tests/ORM/QueryBuilderTest.php
@@ -681,4 +681,32 @@ public function testBCAddJoinWithoutRootAlias()
$this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.groups g', $qb->getDQL());
}
+
+ /**
+ * @group DDC-1211
+ */
+ public function testEmptyStringLiteral()
+ {
+ $expr = $this->_em->getExpressionBuilder();
+ $qb = $this->_em->createQueryBuilder()
+ ->select('u')
+ ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u')
+ ->where($expr->eq('u.username', $expr->literal("")));
+
+ $this->assertEquals("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = ''", $qb->getDQL());
+ }
+
+ /**
+ * @group DDC-1211
+ */
+ public function testEmptyNumericLiteral()
+ {
+ $expr = $this->_em->getExpressionBuilder();
+ $qb = $this->_em->createQueryBuilder()
+ ->select('u')
+ ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u')
+ ->where($expr->eq('u.username', $expr->literal(0)));
+
+ $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 0', $qb->getDQL());
+ }
}

0 comments on commit fff0204

Please sign in to comment.
Something went wrong with that request. Please try again.