Fixed nasty lookup bug when querying for multi-word fuzzy matches using mysql. Resolves #527.
This commit is contained in:
parent
6f25ac913b
commit
81a18ab340
1 changed files with 2 additions and 1 deletions
|
|
@ -216,7 +216,8 @@ class ObjectManager(TypedObjectManager):
|
||||||
key_candidates = self.filter(type_restriction & (Q(db_key__istartswith=ostring) | Q(db_tags__db_key__istartswith=ostring))).distinct()
|
key_candidates = self.filter(type_restriction & (Q(db_key__istartswith=ostring) | Q(db_tags__db_key__istartswith=ostring))).distinct()
|
||||||
candidates_id = [_GA(obj, "id") for obj in key_candidates]
|
candidates_id = [_GA(obj, "id") for obj in key_candidates]
|
||||||
# fuzzy matching
|
# fuzzy matching
|
||||||
key_strings = key_candidates.values_list("db_key", flat=True)
|
key_strings = key_candidates.values_list("db_key", flat=True).order_by("id")
|
||||||
|
|
||||||
index_matches = string_partial_matching(key_strings, ostring, ret_index=True)
|
index_matches = string_partial_matching(key_strings, ostring, ret_index=True)
|
||||||
if index_matches:
|
if index_matches:
|
||||||
return [obj for ind, obj in enumerate(key_candidates) if ind in index_matches]
|
return [obj for ind, obj in enumerate(key_candidates) if ind in index_matches]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue