Skip to content

Commit c438184

Browse files
Add support for GROUP_CONCAT (#44)
1 parent f845214 commit c438184

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/Processor/Expression/FunctionEvaluator.php

+23
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public static function evaluate(
6666
return self::sqlConcatWS($conn, $scope, $expr, $row, $result);
6767
case 'CONCAT':
6868
return self::sqlConcat($conn, $scope, $expr, $row, $result);
69+
case 'GROUP_CONCAT':
70+
return self::sqlGroupConcat($conn, $scope, $expr, $row, $result);
6971
case 'FIELD':
7072
return self::sqlColumn($conn, $scope, $expr, $row, $result);
7173
case 'BINARY':
@@ -932,6 +934,27 @@ private static function sqlConcat(
932934
return $final_concat;
933935
}
934936

937+
/**
938+
* @param array<string, mixed> $row
939+
*/
940+
private static function sqlGroupConcat(
941+
FakePdoInterface $conn,
942+
Scope $scope,
943+
FunctionExpression $expr,
944+
array $row,
945+
QueryResult $result
946+
): string {
947+
$args = $expr->args;
948+
949+
$final_concat = "";
950+
foreach ($args as $arg) {
951+
$val = (string) Evaluator::evaluate($conn, $scope, $arg, $row, $result);
952+
$final_concat .= $val;
953+
}
954+
955+
return $final_concat;
956+
}
957+
935958
/**
936959
* @param array<string, mixed> $row
937960
*

0 commit comments

Comments
 (0)