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.
This commit is contained in:
Julien Fastré 2025-03-14 15:02:26 +01:00
parent 7a9168fcdb
commit f202625ea8
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
2 changed files with 8 additions and 2 deletions

View File

@ -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

View File

@ -75,8 +75,8 @@ final class UserGroupRepository implements UserGroupRepositoryInterface, LocaleA
->setWhereClauses(' ->setWhereClauses('
ug.active AND ( ug.active AND (
SIMILARITY(LOWER(UNACCENT(?)), ug.label->>?) > 0.15 SIMILARITY(LOWER(UNACCENT(?)), ug.label->>?) > 0.15
OR ug.label->>? LIKE \'%\' || LOWER(UNACCENT(?)) || \'%\') OR LOWER(UNACCENT(ug.label->>?)) LIKE \'%\' || LOWER(UNACCENT(?)) || \'%\')
', [$pattern, $lang, $pattern, $lang]); ', [$pattern, $lang, $lang, $pattern]);
return $query; return $query;
} }