1
0
mirror of synced 2024-12-13 22:56:04 +03:00

[DDC-1012] Implemented Expr isNull and isNotNull.

This commit is contained in:
Guilherme Blanco 2011-02-20 01:53:55 -03:00
parent 99c7924292
commit 834203d868
2 changed files with 32 additions and 0 deletions

View File

@ -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.
*

View File

@ -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)));