mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-02 21:13:57 +00:00
fix search on address: do not take deleted one into account
This commit is contained in:
@@ -130,12 +130,13 @@ final class AddressReferenceRepository implements ObjectRepository
|
||||
|
||||
$query
|
||||
->setFromClause('chill_main_address_reference cma')
|
||||
->andWhereClause('postcode_id = ?', [$postalCode->getId()]);
|
||||
->andWhereClause('postcode_id = ?', [$postalCode->getId()])
|
||||
->andWhereClause('deletedAt IS NULL', []);
|
||||
|
||||
$pertinenceClause = ['STRICT_WORD_SIMILARITY(addresscanonical, UNACCENT(?))'];
|
||||
$pertinenceArgs = [$pattern];
|
||||
$orWhere = ['addresscanonical %>> UNACCENT(?)'];
|
||||
$orWhereArgs = [$pattern];
|
||||
$andWhere = [];
|
||||
$andWhereArgs = [];
|
||||
|
||||
foreach (explode(' ', $pattern) as $part) {
|
||||
$part = trim($part);
|
||||
@@ -144,8 +145,8 @@ final class AddressReferenceRepository implements ObjectRepository
|
||||
continue;
|
||||
}
|
||||
|
||||
$orWhere[] = "addresscanonical LIKE '%' || UNACCENT(LOWER(?)) || '%'";
|
||||
$orWhereArgs[] = $part;
|
||||
$andWhere[] = "(addresscanonical LIKE '%' || UNACCENT(LOWER(?)) || '%')";
|
||||
$andWhereArgs[] = $part;
|
||||
$pertinenceClause[] =
|
||||
"(EXISTS (SELECT 1 FROM unnest(string_to_array(addresscanonical, ' ')) AS t WHERE starts_with(t, UNACCENT(LOWER(?)))))::int";
|
||||
$pertinenceClause[] =
|
||||
@@ -154,7 +155,7 @@ final class AddressReferenceRepository implements ObjectRepository
|
||||
}
|
||||
$query
|
||||
->setSelectPertinence(implode(' + ', $pertinenceClause), $pertinenceArgs)
|
||||
->andWhereClause(implode(' OR ', $orWhere), $orWhereArgs);
|
||||
->andWhereClause(implode(' AND ', $andWhere), $andWhereArgs);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
Reference in New Issue
Block a user