1
0
mirror of synced 2025-02-02 21:41:45 +03:00

Merge pull request #1397 from giosh94mhz/concat_expr_variable_arguments

Add Expr::concat support for multiple arguments
This commit is contained in:
Guilherme Blanco 2015-11-07 10:45:04 -05:00
commit d7a3154954
3 changed files with 4 additions and 3 deletions

View File

@ -526,13 +526,13 @@ class Expr
* 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());
}
/**

View File

@ -3464,7 +3464,7 @@ class Parser
/**
* FunctionsReturningStrings ::=
* "CONCAT" "(" StringPrimary "," StringPrimary ")" |
* "CONCAT" "(" StringPrimary "," StringPrimary {"," StringPrimary}* ")" |
* "SUBSTRING" "(" StringPrimary "," SimpleArithmeticExpression "," SimpleArithmeticExpression ")" |
* "TRIM" "(" [["LEADING" | "TRAILING" | "BOTH"] [char] "FROM"] StringPrimary ")" |
* "LOWER" "(" StringPrimary ")" |

View File

@ -184,6 +184,7 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase
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()