Skip to content

Commit

Permalink
fix: prevent error when using PostgreSQL
Browse files Browse the repository at this point in the history
Signed-off-by: Vitor Mattos <[email protected]>
  • Loading branch information
vitormattos committed Nov 30, 2024
1 parent ae5b3e4 commit 912f4d1
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions lib/Db/SignRequestMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,21 @@ private function getFilesAssociatedFilesWithMeStmt(
?array $sort = [],
): Pagination {
$qb = $this->getFilesAssociatedFilesWithMeQueryBuilder($userId, $filter);
if (!empty($sort) && in_array($sort['sortBy'], ['name', 'status', 'created_at'])) {
$qb->orderBy(
$qb->func()->lower('f.' . $sort['sortBy']),
$sort['sortDirection'] == 'asc' ? 'asc' : 'desc'
);
if (!empty($sort['sortBy'])) {
switch ($sort['sortBy']) {
case 'name':
case 'status':
$qb->orderBy(
$qb->func()->lower('f.' . $sort['sortBy']),
$sort['sortDirection'] == 'asc' ? 'asc' : 'desc'
);
break;
case 'created_at':
$qb->orderBy(
'f.' . $sort['sortBy'],
$sort['sortDirection'] == 'asc' ? 'asc' : 'desc'
);
}
}

$countQb = $this->getFilesAssociatedFilesWithMeQueryBuilder(
Expand Down

0 comments on commit 912f4d1

Please sign in to comment.