Skip to content

Commit

Permalink
Merge pull request #1397 from giosh94mhz/concat_expr_variable_arguments
Browse files Browse the repository at this point in the history
Add Expr::concat support for multiple arguments
  • Loading branch information
guilhermeblanco committed Nov 7, 2015
2 parents d88cf97 + 1617253 commit d7a3154
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Query/Expr.php
Expand Up @@ -526,13 +526,13 @@ public function notLike($x, $y)
* Creates a CONCAT() function expression with the given arguments.
*
* @param mixed $x First argument to be used in CONCAT() function.
* @param mixed $y Second argument to be used in CONCAT() function.
* @param mixed $y,... Other arguments to be used in CONCAT() function.
*
* @return Expr\Func
*/
public function concat($x, $y)
{
return new Expr\Func('CONCAT', array($x, $y));
return new Expr\Func('CONCAT', func_get_args());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Query/Parser.php
Expand Up @@ -3464,7 +3464,7 @@ public function CustomFunctionsReturningDatetime()

/**
* FunctionsReturningStrings ::=
* "CONCAT" "(" StringPrimary "," StringPrimary ")" |
* "CONCAT" "(" StringPrimary "," StringPrimary {"," StringPrimary}* ")" |
* "SUBSTRING" "(" StringPrimary "," SimpleArithmeticExpression "," SimpleArithmeticExpression ")" |
* "TRIM" "(" [["LEADING" | "TRAILING" | "BOTH"] [char] "FROM"] StringPrimary ")" |
* "LOWER" "(" StringPrimary ")" |
Expand Down
1 change: 1 addition & 0 deletions tests/Doctrine/Tests/ORM/Query/ExprTest.php
Expand Up @@ -184,6 +184,7 @@ public function testNotLikeExpr()
public function testConcatExpr()
{
$this->assertEquals('CONCAT(u.first_name, u.last_name)', (string) $this->_expr->concat('u.first_name', 'u.last_name'));
$this->assertEquals('CONCAT(u.first_name, u.middle_name, u.last_name)', (string) $this->_expr->concat('u.first_name', 'u.middle_name', 'u.last_name'));
}

public function testSubstringExpr()
Expand Down

0 comments on commit d7a3154

Please sign in to comment.