mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fixed: narrow search on postal code with an 'AND' clause instead of 'OR' clause
This commit is contained in:
parent
1d8f25e2c8
commit
94c258e914
@ -119,8 +119,8 @@ final class PostalCodeRepository implements ObjectRepository
|
||||
|
||||
$pertinenceClause = ['STRICT_WORD_SIMILARITY(canonical, UNACCENT(?))'];
|
||||
$pertinenceArgs = [$pattern];
|
||||
$orWhere = ['canonical %>> UNACCENT(?)'];
|
||||
$orWhereArgs = [$pattern];
|
||||
$andWhere = ['canonical %>> UNACCENT(?)'];
|
||||
$andWhereArgs = [$pattern];
|
||||
|
||||
foreach (explode(' ', $pattern) as $part) {
|
||||
$part = trim($part);
|
||||
@ -129,8 +129,8 @@ final class PostalCodeRepository implements ObjectRepository
|
||||
continue;
|
||||
}
|
||||
|
||||
$orWhere[] = "canonical LIKE '%' || UNACCENT(LOWER(?)) || '%'";
|
||||
$orWhereArgs[] = $part;
|
||||
$andWhere[] = "canonical LIKE '%' || UNACCENT(LOWER(?)) || '%'";
|
||||
$andWhereArgs[] = $part;
|
||||
$pertinenceClause[] =
|
||||
"(EXISTS (SELECT 1 FROM unnest(string_to_array(canonical, ' ')) AS t WHERE starts_with(t, UNACCENT(LOWER(?)))))::int";
|
||||
$pertinenceClause[] =
|
||||
@ -139,7 +139,7 @@ final class PostalCodeRepository implements ObjectRepository
|
||||
}
|
||||
$query
|
||||
->setSelectPertinence(implode(' + ', $pertinenceClause), $pertinenceArgs)
|
||||
->andWhereClause(implode(' OR ', $orWhere), $orWhereArgs);
|
||||
->andWhereClause(implode(' AND ', $andWhere), $andWhereArgs);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user