Skip to content

Commit 2b891da

Browse files
authored
Merge pull request #4082 from LibreSign/backport/4080/stable30
[stable30] fix: prevent error when using PostgreSQL
2 parents 8907d32 + ffd9228 commit 2b891da

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

lib/Db/SignRequestMapper.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -531,11 +531,21 @@ private function getFilesAssociatedFilesWithMeStmt(
531531
?array $sort = [],
532532
): Pagination {
533533
$qb = $this->getFilesAssociatedFilesWithMeQueryBuilder($userId, $filter);
534-
if (!empty($sort) && in_array($sort['sortBy'], ['name', 'status', 'created_at'])) {
535-
$qb->orderBy(
536-
$qb->func()->lower('f.' . $sort['sortBy']),
537-
$sort['sortDirection'] == 'asc' ? 'asc' : 'desc'
538-
);
534+
if (!empty($sort['sortBy'])) {
535+
switch ($sort['sortBy']) {
536+
case 'name':
537+
case 'status':
538+
$qb->orderBy(
539+
$qb->func()->lower('f.' . $sort['sortBy']),
540+
$sort['sortDirection'] == 'asc' ? 'asc' : 'desc'
541+
);
542+
break;
543+
case 'created_at':
544+
$qb->orderBy(
545+
'f.' . $sort['sortBy'],
546+
$sort['sortDirection'] == 'asc' ? 'asc' : 'desc'
547+
);
548+
}
539549
}
540550

541551
$countQb = $this->getFilesAssociatedFilesWithMeQueryBuilder(

0 commit comments

Comments
 (0)