Merge branch 'master' of github.com:doctrine/doctrine2
This commit is contained in:
commit
b9965bfb1c
4
.gitignore
vendored
4
.gitignore
vendored
@ -5,5 +5,5 @@ reports/
|
|||||||
dist/
|
dist/
|
||||||
download/
|
download/
|
||||||
lib/api/
|
lib/api/
|
||||||
lib/Doctrine/Common/
|
lib/Doctrine/Common
|
||||||
lib/Doctrine/DBAL/
|
lib/Doctrine/DBAL
|
||||||
|
@ -470,9 +470,13 @@ class Expr
|
|||||||
* @param integer $len Length of crop. May accept negative values.
|
* @param integer $len Length of crop. May accept negative values.
|
||||||
* @return Expr\Func
|
* @return Expr\Func
|
||||||
*/
|
*/
|
||||||
public function substring($x, $from, $len)
|
public function substring($x, $from, $len = null)
|
||||||
{
|
{
|
||||||
return new Expr\Func('SUBSTRING', array($x, $from, $len));
|
$args = array($x, $from);
|
||||||
|
if (null !== $len) {
|
||||||
|
$args[] = $len;
|
||||||
|
}
|
||||||
|
return new Expr\Func('SUBSTRING', $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -185,6 +185,15 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
$this->assertEquals('SUBSTRING(a.title, 0, 25)', (string) $this->_expr->substring('a.title', 0, 25));
|
$this->assertEquals('SUBSTRING(a.title, 0, 25)', (string) $this->_expr->substring('a.title', 0, 25));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group regression
|
||||||
|
* @group DDC-612
|
||||||
|
*/
|
||||||
|
public function testSubstringExprAcceptsTwoArguments()
|
||||||
|
{
|
||||||
|
$this->assertEquals('SUBSTRING(a.title, 0)', (string) $this->_expr->substring('a.title', 5));
|
||||||
|
}
|
||||||
|
|
||||||
public function testLowerExpr()
|
public function testLowerExpr()
|
||||||
{
|
{
|
||||||
$this->assertEquals('LOWER(u.first_name)', (string) $this->_expr->lower('u.first_name'));
|
$this->assertEquals('LOWER(u.first_name)', (string) $this->_expr->lower('u.first_name'));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user