From 64d99aaf1144c94a3ebd9ab675bd785e8013f0fb Mon Sep 17 00:00:00 2001 From: Griatch Date: Sat, 23 Mar 2019 21:33:41 +0100 Subject: [PATCH] Fix race condition bug in search discovered by comparing with postgres result --- evennia/commands/default/tests.py | 6 ++---- evennia/objects/manager.py | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/evennia/commands/default/tests.py b/evennia/commands/default/tests.py index 6b2caa4245..2b157e91ba 100644 --- a/evennia/commands/default/tests.py +++ b/evennia/commands/default/tests.py @@ -444,13 +444,11 @@ class TestBuilding(CommandTest): building.CmdDestroy.confirm = False self.call(building.CmdDestroy(), "", "Usage: ") self.call(building.CmdDestroy(), "Obj", "Obj was destroyed.") - settings.DEFAULT_HOME = self.room1.dbref self.call(building.CmdDestroy(), "Obj", "Obj2 was destroyed.") self.call(building.CmdDestroy(), "Obj", "Could not find 'Obj'.| (Objects to destroy " "must either be local or specified with a unique #dbref.)") - default_home_dbref = settings.DEFAULT_HOME - self.call(building.CmdDestroy(), default_home_dbref, - "You are trying to delete") # DEFAULT_HOME + self.call(building.CmdDestroy(), settings.DEFAULT_HOME, + "You are trying to delete") # DEFAULT_HOME should not be deleted self.char2.location = self.room2 charid = self.char2.id room1id = self.room1.id diff --git a/evennia/objects/manager.py b/evennia/objects/manager.py index ba1cc9fa8d..c4f256ddb2 100644 --- a/evennia/objects/manager.py +++ b/evennia/objects/manager.py @@ -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")