Return no match if using obj.search() with an empty list of candidates. This accounts for candidate lists that are created dynamically, for example limiting them to the inventory (which may be empy). Resolves #1016.

This commit is contained in:
Griatch 2016-08-20 11:00:33 +02:00
parent ca1b76ab02
commit 1da9217a18
3 changed files with 6 additions and 3 deletions

View file

@ -1155,7 +1155,7 @@ class ContribRPObject(DefaultObject):
# only allow exact matching if searching the entire database
# or unique #dbrefs
exact = True
elif not candidates:
elif candidates is None:
# no custom candidates given - get them automatically
if location:
# location(s) were given

View file

@ -357,7 +357,10 @@ class ObjectDBManager(TypedObjectManager):
typeclasses[i] = u"%s" % typeclass
typeclass = typeclasses
if candidates:
if candidates is not None:
if not candidates:
# candidates is the empty list. This should mean no matches can ever be acquired.
return []
# Convenience check to make sure candidates are really dbobjs
candidates = [cand for cand in make_iter(candidates) if cand]
if typeclass:

View file

@ -361,7 +361,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
# only allow exact matching if searching the entire database
# or unique #dbrefs
exact = True
elif not candidates:
elif candidates is None:
# no custom candidates given - get them automatically
if location:
# location(s) were given