From f202625ea834e3f0fee691bedf3bfd4ac414b695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 14 Mar 2025 15:02:26 +0100 Subject: [PATCH] Fix LIKE clause logic in UserGroupRepository query Adjusted the parameter order and ensured consistent use of LOWER and UNACCENT functions in the LIKE clause. This resolves potential mismatches and improves query reliability for pattern matching. --- .changes/unreleased/Fixed-20250314-150408.yaml | 6 ++++++ .../ChillMainBundle/Repository/UserGroupRepository.php | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changes/unreleased/Fixed-20250314-150408.yaml diff --git a/.changes/unreleased/Fixed-20250314-150408.yaml b/.changes/unreleased/Fixed-20250314-150408.yaml new file mode 100644 index 000000000..0c278aa12 --- /dev/null +++ b/.changes/unreleased/Fixed-20250314-150408.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: fix search query for user groups +time: 2025-03-14T15:04:08.622666838+01:00 +custom: + Issue: "368" + SchemaChange: No schema change diff --git a/src/Bundle/ChillMainBundle/Repository/UserGroupRepository.php b/src/Bundle/ChillMainBundle/Repository/UserGroupRepository.php index e1c54442d..71266f8e5 100644 --- a/src/Bundle/ChillMainBundle/Repository/UserGroupRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/UserGroupRepository.php @@ -75,8 +75,8 @@ final class UserGroupRepository implements UserGroupRepositoryInterface, LocaleA ->setWhereClauses(' ug.active AND ( SIMILARITY(LOWER(UNACCENT(?)), ug.label->>?) > 0.15 - OR ug.label->>? LIKE \'%\' || LOWER(UNACCENT(?)) || \'%\') - ', [$pattern, $lang, $pattern, $lang]); + OR LOWER(UNACCENT(ug.label->>?)) LIKE \'%\' || LOWER(UNACCENT(?)) || \'%\') + ', [$pattern, $lang, $lang, $pattern]); return $query; }