Skip to content

Commit

Permalink
Merge branch 'master' of github.com:doctrine/doctrine2
Browse files Browse the repository at this point in the history
  • Loading branch information
jwage committed May 25, 2010
2 parents adcdefd + 93701e6 commit b9965bf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Expand Up @@ -5,5 +5,5 @@ reports/
dist/
download/
lib/api/
lib/Doctrine/Common/
lib/Doctrine/DBAL/
lib/Doctrine/Common
lib/Doctrine/DBAL
8 changes: 6 additions & 2 deletions lib/Doctrine/ORM/Query/Expr.php
Expand Up @@ -470,9 +470,13 @@ public function concat($x, $y)
* @param integer $len Length of crop. May accept negative values.
* @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);
}

/**
Expand Down
9 changes: 9 additions & 0 deletions tests/Doctrine/Tests/ORM/Query/ExprTest.php
Expand Up @@ -185,6 +185,15 @@ public function testSubstringExpr()
$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()
{
$this->assertEquals('LOWER(u.first_name)', (string) $this->_expr->lower('u.first_name'));
Expand Down

0 comments on commit b9965bf

Please sign in to comment.