summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Comments/Manager.php9
-rw-r--r--lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php2
-rw-r--r--lib/private/DB/QueryBuilder/FunctionBuilder/OCIFunctionBuilder.php4
-rw-r--r--lib/private/DB/QueryBuilder/FunctionBuilder/PgSqlFunctionBuilder.php2
-rw-r--r--lib/private/DB/QueryBuilder/FunctionBuilder/SqliteFunctionBuilder.php2
5 files changed, 10 insertions, 9 deletions
diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php
index 2e9acb6ca24..410fcf26f4d 100644
--- a/lib/private/Comments/Manager.php
+++ b/lib/private/Comments/Manager.php
@@ -1210,20 +1210,21 @@ class Manager implements ICommentsManager {
$totalQuery->expr()->literal('":'),
$totalQuery->func()->count('id')
),
- 'total'
+ 'colonseparatedvalue'
)
+ ->selectAlias($totalQuery->func()->count('id'), 'total')
->from('reactions', 'r')
->where($totalQuery->expr()->eq('r.parent_id', $qb->createNamedParameter($parentId)))
->groupBy('r.reaction')
- ->orderBy($totalQuery->func()->count('id'), 'DESC')
+ ->orderBy('total', 'DESC')
->setMaxResults(200);
$jsonQuery = $this->dbConn->getQueryBuilder();
$jsonQuery
->selectAlias(
- $totalQuery->func()->concat(
+ $jsonQuery->func()->concat(
$jsonQuery->expr()->literal('{'),
- $jsonQuery->func()->groupConcat('total'),
+ $jsonQuery->func()->groupConcat('colonseparatedvalue', ',', $jsonQuery->getColumnName('total') . ' DESC'),
$jsonQuery->expr()->literal('}')
),
'json'
diff --git a/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php b/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php
index 03630ea14a3..ba59f42ce5d 100644
--- a/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php
+++ b/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php
@@ -59,7 +59,7 @@ class FunctionBuilder implements IFunctionBuilder {
return new QueryFunction(sprintf('CONCAT(%s)', implode(', ', $list)));
}
- public function groupConcat($expr, ?string $separator = ','): IQueryFunction {
+ public function groupConcat($expr, ?string $separator = ',', ?string $orderBy = null): IQueryFunction {
$separator = $this->connection->quote($separator);
return new QueryFunction('GROUP_CONCAT(' . $this->helper->quoteColumnName($expr) . ' SEPARATOR ' . $separator . ')');
}
diff --git a/lib/private/DB/QueryBuilder/FunctionBuilder/OCIFunctionBuilder.php b/lib/private/DB/QueryBuilder/FunctionBuilder/OCIFunctionBuilder.php
index 43ecf599eba..77f14a2dda4 100644
--- a/lib/private/DB/QueryBuilder/FunctionBuilder/OCIFunctionBuilder.php
+++ b/lib/private/DB/QueryBuilder/FunctionBuilder/OCIFunctionBuilder.php
@@ -82,8 +82,8 @@ class OCIFunctionBuilder extends FunctionBuilder {
return new QueryFunction(sprintf('(%s)', implode(' || ', $list)));
}
- public function groupConcat($expr, ?string $separator = ','): IQueryFunction {
- $orderByClause = ' WITHIN GROUP(ORDER BY NULL)';
+ public function groupConcat($expr, ?string $separator = ',', ?string $orderBy = 'NULL'): IQueryFunction {
+ $orderByClause = ' WITHIN GROUP(ORDER BY ' . $orderBy . ')';
if (is_null($separator)) {
return new QueryFunction('LISTAGG(' . $this->helper->quoteColumnName($expr) . ')' . $orderByClause);
}
diff --git a/lib/private/DB/QueryBuilder/FunctionBuilder/PgSqlFunctionBuilder.php b/lib/private/DB/QueryBuilder/FunctionBuilder/PgSqlFunctionBuilder.php
index 444f6aa83a4..3a1d9a56734 100644
--- a/lib/private/DB/QueryBuilder/FunctionBuilder/PgSqlFunctionBuilder.php
+++ b/lib/private/DB/QueryBuilder/FunctionBuilder/PgSqlFunctionBuilder.php
@@ -37,7 +37,7 @@ class PgSqlFunctionBuilder extends FunctionBuilder {
return new QueryFunction(sprintf('(%s)', implode(' || ', $list)));
}
- public function groupConcat($expr, ?string $separator = ','): IQueryFunction {
+ public function groupConcat($expr, ?string $separator = ',', ?string $orderBy = null): IQueryFunction {
$castedExpression = $this->queryBuilder->expr()->castColumn($expr, IQueryBuilder::PARAM_STR);
if (is_null($separator)) {
diff --git a/lib/private/DB/QueryBuilder/FunctionBuilder/SqliteFunctionBuilder.php b/lib/private/DB/QueryBuilder/FunctionBuilder/SqliteFunctionBuilder.php
index fe700075a82..cfcabc9eb1a 100644
--- a/lib/private/DB/QueryBuilder/FunctionBuilder/SqliteFunctionBuilder.php
+++ b/lib/private/DB/QueryBuilder/FunctionBuilder/SqliteFunctionBuilder.php
@@ -36,7 +36,7 @@ class SqliteFunctionBuilder extends FunctionBuilder {
return new QueryFunction(sprintf('(%s)', implode(' || ', $list)));
}
- public function groupConcat($expr, ?string $separator = ','): IQueryFunction {
+ public function groupConcat($expr, ?string $separator = ',', ?string $orderBy = null): IQueryFunction {
$separator = $this->connection->quote($separator);
return new QueryFunction('GROUP_CONCAT(' . $this->helper->quoteColumnName($expr) . ', ' . $separator . ')');
}