DDC-1211 - Fix bug with empty numeric literal
This commit is contained in:
parent
1c2ade61ab
commit
c7c430032c
@ -55,7 +55,7 @@ abstract class Base
|
||||
|
||||
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);
|
||||
|
@ -681,4 +681,32 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase
|
||||
|
||||
$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());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user