Don't add empty expression to another one
This commit is contained in:
parent
ce0dd1c4f4
commit
8b8d1a5aaa
@ -86,7 +86,7 @@ abstract class Base
|
||||
*/
|
||||
public function add($arg)
|
||||
{
|
||||
if ( $arg !== null || ($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);
|
||||
|
@ -414,4 +414,18 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase
|
||||
$select = new Expr\Select(array('foo', 'bar'));
|
||||
$this->assertEquals(array('foo', 'bar'), $select->getParts());
|
||||
}
|
||||
|
||||
public function testAddEmpty() {
|
||||
$andExpr = $this->_expr->andx();
|
||||
$andExpr->add($this->_expr->andx());
|
||||
|
||||
$this->assertEquals(0, $andExpr->count());
|
||||
}
|
||||
|
||||
public function testAddNull() {
|
||||
$andExpr = $this->_expr->andx();
|
||||
$andExpr->add(null);
|
||||
|
||||
$this->assertEquals(0, $andExpr->count());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user