evennia / evennia

Python MUD/MUX/MUSH/MU* development system

Home Page:http://www.evennia.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] `search_object` can return erroneous matches when tags are provided

InspectorCaracal opened this issue · comments

Describe the bug

If the original search regardless of tags would have returned no matches, it instead returns all objects everywhere that have the matching tag.

To Reproduce

Steps to reproduce the behavior:

  1. Choose a search that you know will return no matches: for example, if there are no objects named "Bob", do search_object("Bob") and confirm it finds zero matches.
  2. Add a tag/category filter that you know are in the game, like ("greatsword","prototype_key") or something: search_object("Bob", tags=[("greatsword", "prototype_key")])
  3. See error

Here's a real-world example:

>>> search_object("bob")
<QuerySet []>
[py mode - quit() to exit]
>>> search_object("bob", tags=[('tester#2-iron river', 'game')])
<QuerySet [Haunting music box, Pancake mix, Bag of hard candies, Cream]>
[py mode - quit() to exit]

Expected behavior

It should still be zero matches.

Environment, Evennia version, OS etc

Evennia 3.2.0, Windows 10

Additional context

The problem is due to this:

if not query:
query = self.all()

In the case where the query being handed to it is zero matches, it's using the entire ObjectDB table as a base instead of simply returning no matches. I'm not sure why this behavior was written, so I'm not sure if it would be correct to change it to just return query at that point instead.