[DDC-1012] Implemented Expr isNull and isNotNull.
This commit is contained in:
parent
99c7924292
commit
834203d868
@ -443,6 +443,28 @@ class Expr
|
||||
return new Expr\Func($x . ' NOT IN', (array) $y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an IS NULL expression with the given arguments.
|
||||
*
|
||||
* @param string $x Field in string format to be restricted by IS NULL
|
||||
* @return string
|
||||
*/
|
||||
public function isNull($x)
|
||||
{
|
||||
return $x . ' IS NULL';
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an IS NOT NULL expression with the given arguments.
|
||||
*
|
||||
* @param string $x Field in string format to be restricted by IS NOT NULL
|
||||
* @return string
|
||||
*/
|
||||
public function isNotNull($x)
|
||||
{
|
||||
return $x . ' IS NOT NULL';
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a LIKE() comparison expression with the given arguments.
|
||||
*
|
||||
|
@ -256,6 +256,16 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase
|
||||
$this->assertEquals('TRIM(u.id)', (string) $this->_expr->trim('u.id'));
|
||||
}
|
||||
|
||||
public function testIsNullExpr()
|
||||
{
|
||||
$this->assertEquals('u.id IS NULL', (string) $this->_expr->isNull('u.id'));
|
||||
}
|
||||
|
||||
public function testIsNotNullExpr()
|
||||
{
|
||||
$this->assertEquals('u.id IS NOT NULL', (string) $this->_expr->isNotNull('u.id'));
|
||||
}
|
||||
|
||||
public function testInExpr()
|
||||
{
|
||||
$this->assertEquals('u.id IN(1, 2, 3)', (string) $this->_expr->in('u.id', array(1, 2, 3)));
|
||||
|
Loading…
Reference in New Issue
Block a user