Skip to content

Commit

Permalink
Add support for GROUP_CONCAT (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
MelechMizrachi authored May 8, 2024
1 parent f845214 commit c438184
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Processor/Expression/FunctionEvaluator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -932,6 +934,27 @@ private static function sqlConcat(
return $final_concat;
}

/**
* @param array<string, mixed> $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<string, mixed> $row
*
Expand Down

0 comments on commit c438184

Please sign in to comment.