Fix race condition bug in search discovered by comparing with postgres result

This commit is contained in:
Griatch 2019-03-23 21:33:41 +01:00
parent fa3588be20
commit 64d99aaf11
2 changed files with 4 additions and 6 deletions

View file

@ -268,11 +268,11 @@ class ObjectDBManager(TypedObjectManager):
Q(db_tags__db_key__iexact=ostring) & Q(db_tags__db_tagtype__iexact="alias"))).distinct()
elif candidates:
# fuzzy with candidates
search_candidates = self.filter(cand_restriction & type_restriction)
search_candidates = self.filter(cand_restriction & type_restriction).order_by('id')
else:
# fuzzy without supplied candidates - we select our own candidates
search_candidates = self.filter(type_restriction & (Q(db_key__istartswith=ostring) |
Q(db_tags__db_key__istartswith=ostring))).distinct()
Q(db_tags__db_key__istartswith=ostring))).distinct().order_by('id')
# fuzzy matching
key_strings = search_candidates.values_list("db_key", flat=True).order_by("id")