From d8e5f5d3f316b7378bc8874832d3c93ea81380cd Mon Sep 17 00:00:00 2001 From: Ben Longden Date: Tue, 20 Apr 2021 22:30:10 +0100 Subject: [PATCH] Don't allow fuzzy match on db if exact match on module prototype --- evennia/prototypes/prototypes.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/evennia/prototypes/prototypes.py b/evennia/prototypes/prototypes.py index 185b9dfc5d..a304dd8684 100644 --- a/evennia/prototypes/prototypes.py +++ b/evennia/prototypes/prototypes.py @@ -379,10 +379,12 @@ def search_prototype(key=None, tags=None, require_single=False, return_iterators else: mod_matches = _MODULE_PROTOTYPES + allow_fuzzy = True if key: if key in mod_matches: # exact match module_prototypes = [mod_matches[key]] + allow_fuzzy = False else: # fuzzy matching module_prototypes = [ @@ -406,7 +408,7 @@ def search_prototype(key=None, tags=None, require_single=False, return_iterators if key: # exact or partial match on key exact_match = db_matches.filter(Q(db_key__iexact=key)).order_by("db_key") - if not exact_match: + if not exact_match and allow_fuzzy: # try with partial match instead db_matches = db_matches.filter(Q(db_key__icontains=key)).order_by("db_key") else: @@ -423,7 +425,7 @@ def search_prototype(key=None, tags=None, require_single=False, return_iterators nmodules = len(module_prototypes) ndbprots = db_matches.count() if nmodules + ndbprots != 1: - raise KeyError(f"Found {nmodules + ndbprots} matching prototypes.") + raise KeyError(f"Found {nmodules + ndbprots} matching prototypes {module_prototypes}.") if return_iterators: # trying to get the entire set of prototypes - we must paginate