Skip to content

Commit

Permalink
fix: add pending group by
Browse files Browse the repository at this point in the history
JSON column with postgre need to be converted first to text to be
possible use at group by

Signed-off-by: Vitor Mattos <[email protected]>
  • Loading branch information
vitormattos authored and backportbot-libresign[bot] committed Apr 8, 2024
1 parent 88ce2ab commit 47ab22d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/Db/SignRequestMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

namespace OCA\Libresign\Db;

use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use OCA\Libresign\Helper\Pagination;
use OCA\Libresign\Service\IdentifyMethod\IIdentifyMethod;
use OCA\Libresign\Service\IdentifyMethodService;
Expand Down Expand Up @@ -464,6 +465,13 @@ private function getFilesAssociatedFilesWithMeQueryBuilder(string $userId, ?stri
'f.status',
'f.created_at',
);
// metadata is a json column, the right way is to use f.metadata::text
// when the database is PostgreSQL. The problem is that the command
// addGroupBy add quotes over all text send as argument. With
// PostgreSQL json columns don't have problem if not added to group by.
if (!$qb->getConnection()->getDatabasePlatform() instanceof PostgreSQLPlatform) {
$qb->addGroupBy('f.metadata');
}

$or = [
$qb->expr()->eq('f.user_id', $qb->createNamedParameter($userId)),
Expand Down
8 changes: 8 additions & 0 deletions tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@
<code>callable(QueryBuilder): void</code>
</UndefinedDocblockClass>
</file>
<file src="lib/Db/SignRequestMapper.php">
<UndefinedClass occurrences="1">
<code>PostgreSQLPlatform</code>
</UndefinedClass>
<UndefinedDocblockClass occurrences="1">
<code>$qb-&gt;getConnection()-&gt;getDatabasePlatform()</code>
</UndefinedDocblockClass>
</file>
<file src="lib/Files/TemplateLoader.php">
<UndefinedClass occurrences="2">
<code>LoadSidebar</code>
Expand Down

0 comments on commit 47ab22d

Please sign in to comment.