From b75fadd15c1422c1e25468cc624080f1bf504b8a Mon Sep 17 00:00:00 2001 From: Melech Mizrachi Date: Tue, 12 Mar 2024 08:13:07 -0700 Subject: [PATCH] Add support for `GROUP_CONCAT` --- .../Expression/FunctionEvaluator.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/Processor/Expression/FunctionEvaluator.php b/src/Processor/Expression/FunctionEvaluator.php index 90e79d05..e8effd46 100644 --- a/src/Processor/Expression/FunctionEvaluator.php +++ b/src/Processor/Expression/FunctionEvaluator.php @@ -66,6 +66,8 @@ public static function evaluate( return self::sqlConcatWS($conn, $scope, $expr, $row, $result); case 'CONCAT': return self::sqlConcat($conn, $scope, $expr, $row, $result); + case 'GROUP_CONCAT': + return self::sqlGroupConcat($conn, $scope, $expr, $row, $result); case 'FIELD': return self::sqlColumn($conn, $scope, $expr, $row, $result); case 'BINARY': @@ -932,6 +934,27 @@ private static function sqlConcat( return $final_concat; } + /** + * @param array $row + */ + private static function sqlGroupConcat( + FakePdoInterface $conn, + Scope $scope, + FunctionExpression $expr, + array $row, + QueryResult $result + ): string { + $args = $expr->args; + + $final_concat = ""; + foreach ($args as $arg) { + $val = (string) Evaluator::evaluate($conn, $scope, $arg, $row, $result); + $final_concat .= $val; + } + + return $final_concat; + } + /** * @param array $row *