MDL-52817 dml: implement driver methods for SQL group concatenation.
This commit is contained in:
@@ -1452,6 +1452,19 @@ class pgsql_native_moodle_database extends moodle_database {
|
||||
return " $s ";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return SQL for performing group concatenation on given field/expression
|
||||
*
|
||||
* @param string $field
|
||||
* @param string $separator
|
||||
* @param string $sort
|
||||
* @return string
|
||||
*/
|
||||
public function sql_group_concat(string $field, string $separator = ', ', string $sort = ''): string {
|
||||
$fieldsort = $sort ? "ORDER BY {$sort}" : '';
|
||||
return "STRING_AGG(CAST({$field} AS VARCHAR), '{$separator}' {$fieldsort})";
|
||||
}
|
||||
|
||||
public function sql_regex_supported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user