From 47ab22d7c724b138676acc3dba33ef97a22de3a4 Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Mon, 8 Apr 2024 16:18:56 -0300 Subject: [PATCH] fix: add pending group by JSON column with postgre need to be converted first to text to be possible use at group by Signed-off-by: Vitor Mattos --- lib/Db/SignRequestMapper.php | 8 ++++++++ tests/psalm-baseline.xml | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/Db/SignRequestMapper.php b/lib/Db/SignRequestMapper.php index a4e05952fa..258d7cc2a5 100644 --- a/lib/Db/SignRequestMapper.php +++ b/lib/Db/SignRequestMapper.php @@ -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; @@ -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)), diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml index 0e69cf47a7..0c7fde2668 100644 --- a/tests/psalm-baseline.xml +++ b/tests/psalm-baseline.xml @@ -55,6 +55,14 @@ callable(QueryBuilder): void + + + PostgreSQLPlatform + + + $qb->getConnection()->getDatabasePlatform() + + LoadSidebar