diff --git a/src/objects/manager.py b/src/objects/manager.py index 9303c9a06d..eb8257a365 100644 --- a/src/objects/manager.py +++ b/src/objects/manager.py @@ -206,7 +206,7 @@ class ObjectManager(TypedObjectManager): # fuzzy matching - first check with keys, then with aliases key_candidates = self.filter(Q(db_key__istartswith=ostring) | Q(alias__db_key__istartswith=ostring)).distinct() key_strings = key_candidates.values_list("db_key", flat=True) - matches = string_partial_matching(key_candidates, ostring, reg_index=False) + matches = string_partial_matching(key_candidates, ostring, ret_index=False) if matches: return matches alias_candidates = self.model.alias_set.related.model.objects.filter(db_obj__pk__in=candidates_id).values_list("db_key", flat=True) @@ -267,16 +267,23 @@ class ObjectManager(TypedObjectManager): if not ostring and ostring != 0: return [] + # Convenience check to make sure candidates are really dbobjs + if candidates: + candidates = [cand.dbobj for cand in make_iter(candidates) if hasattr(cand, "dbobj")] + + # If there are no candidates, don't go any further. + if candidates == []: + return [] + dbref = not attribute_name and self.dbref(ostring) if dbref or dbref == 0: # Easiest case - dbref matching (always exact) dbref_match = self.dbref_search(dbref) if dbref_match: - return [dbref_match] - - # Convenience check to make sure candidates are really dbobjs - if candidates: - candidates = [cand.dbobj for cand in make_iter(candidates) if hasattr(cand, "dbobj")] + if candidates == None or dbref_match.dbobj in candidates: + return [dbref_match] + else: + return [] # Search through all possibilities.