From 16172534bb7e10c378050808170b1f18d1c15b22 Mon Sep 17 00:00:00 2001
From: Giorgio Premi <giosh94mhz@gmail.com>
Date: Tue, 28 Apr 2015 10:30:23 +0200
Subject: [PATCH] Add Expr::concat support for multiple arguments

---
 lib/Doctrine/ORM/Query/Expr.php             | 4 ++--
 lib/Doctrine/ORM/Query/Parser.php           | 2 +-
 tests/Doctrine/Tests/ORM/Query/ExprTest.php | 1 +
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/Doctrine/ORM/Query/Expr.php b/lib/Doctrine/ORM/Query/Expr.php
index b6997d8cb..e82c4fe25 100644
--- a/lib/Doctrine/ORM/Query/Expr.php
+++ b/lib/Doctrine/ORM/Query/Expr.php
@@ -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());
     }
 
     /**
diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php
index 442dbac80..deacc8088 100644
--- a/lib/Doctrine/ORM/Query/Parser.php
+++ b/lib/Doctrine/ORM/Query/Parser.php
@@ -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 ")" |
diff --git a/tests/Doctrine/Tests/ORM/Query/ExprTest.php b/tests/Doctrine/Tests/ORM/Query/ExprTest.php
index 91135128c..5d305b6a4 100644
--- a/tests/Doctrine/Tests/ORM/Query/ExprTest.php
+++ b/tests/Doctrine/Tests/ORM/Query/ExprTest.php
@@ -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()