Remove order from groupConcat as it is not working everywhere

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2022-01-17 11:58:50 +01:00 committed by Vitor Mattos
parent 189f9f96ce
commit d850dc0220
No known key found for this signature in database
GPG key ID: B7AB4B76A7CA7318
6 changed files with 7 additions and 8 deletions

View file

@ -1233,7 +1233,7 @@ class Manager implements ICommentsManager {
->selectAlias(
$jsonQuery->func()->concat(
$jsonQuery->expr()->literal('{'),
$jsonQuery->func()->groupConcat('colonseparatedvalue', ','),
$jsonQuery->func()->groupConcat('colonseparatedvalue'),
$jsonQuery->expr()->literal('}')
),
'json'

View file

@ -59,7 +59,7 @@ class FunctionBuilder implements IFunctionBuilder {
return new QueryFunction(sprintf('CONCAT(%s)', implode(', ', $list)));
}
public function groupConcat($expr, ?string $separator = ',', ?string $orderBy = null): IQueryFunction {
public function groupConcat($expr, ?string $separator = ','): IQueryFunction {
$separator = $this->connection->quote($separator);
return new QueryFunction('GROUP_CONCAT(' . $this->helper->quoteColumnName($expr) . ' SEPARATOR ' . $separator . ')');
}

View file

@ -82,8 +82,8 @@ class OCIFunctionBuilder extends FunctionBuilder {
return new QueryFunction(sprintf('(%s)', implode(' || ', $list)));
}
public function groupConcat($expr, ?string $separator = ',', ?string $orderBy = 'NULL'): IQueryFunction {
$orderByClause = ' WITHIN GROUP(ORDER BY ' . $orderBy . ')';
public function groupConcat($expr, ?string $separator = ','): IQueryFunction {
$orderByClause = ' WITHIN GROUP(ORDER BY NULL)';
if (is_null($separator)) {
return new QueryFunction('LISTAGG(' . $this->helper->quoteColumnName($expr) . ')' . $orderByClause);
}

View file

@ -37,7 +37,7 @@ class PgSqlFunctionBuilder extends FunctionBuilder {
return new QueryFunction(sprintf('(%s)', implode(' || ', $list)));
}
public function groupConcat($expr, ?string $separator = ',', ?string $orderBy = null): IQueryFunction {
public function groupConcat($expr, ?string $separator = ','): IQueryFunction {
$castedExpression = $this->queryBuilder->expr()->castColumn($expr, IQueryBuilder::PARAM_STR);
if (is_null($separator)) {

View file

@ -36,7 +36,7 @@ class SqliteFunctionBuilder extends FunctionBuilder {
return new QueryFunction(sprintf('(%s)', implode(' || ', $list)));
}
public function groupConcat($expr, ?string $separator = ',', ?string $orderBy = null): IQueryFunction {
public function groupConcat($expr, ?string $separator = ','): IQueryFunction {
$separator = $this->connection->quote($separator);
return new QueryFunction('GROUP_CONCAT(' . $this->helper->quoteColumnName($expr) . ', ' . $separator . ')');
}

View file

@ -62,11 +62,10 @@ interface IFunctionBuilder {
*
* @param string|IQueryFunction $expr The expression to group
* @param string|null $separator The separator
* @param string|null $orderBy Option only used to make compatible with Oracle database if is necessary use order. The default value is null and the Oracle don't will respect the order by of query
* @return IQueryFunction
* @since 24.0.0
*/
public function groupConcat($expr, ?string $separator = ',', ?string $orderBy = null): IQueryFunction;
public function groupConcat($expr, ?string $separator = ','): IQueryFunction;
/**
* Takes a substring from the input string