mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Fix bug in tag querying. Resolve #2688.
This commit is contained in:
parent
66e03d4a59
commit
bf7f8e63c5
2 changed files with 19 additions and 0 deletions
|
|
@ -197,6 +197,8 @@ class TypedObjectManager(idmapper.manager.SharedMemoryManager):
|
|||
query.append(("db_key", key))
|
||||
if category:
|
||||
query.append(("db_category", category))
|
||||
else:
|
||||
query.append(("db_category", None))
|
||||
return _Tag.objects.filter(**dict(query))
|
||||
else:
|
||||
# search only among tags stored on on this model
|
||||
|
|
|
|||
|
|
@ -314,6 +314,23 @@ class TestTags(BaseEvenniaTest):
|
|||
self.obj1.tags.add("tagC", "categoryC")
|
||||
self.assertFalse(self.obj1.tags.has(category="categoryD"))
|
||||
|
||||
def test_tag_add_no_category__issue_2688(self):
|
||||
"""
|
||||
Adding a tag without a category should create a new tag:None tag
|
||||
rather than trying to update an existing tag:category tag.
|
||||
"""
|
||||
# adding tag+category, creates tag+category entry
|
||||
self.obj1.tags.add("testing", category="testing_category")
|
||||
self.assertEqual(
|
||||
self.obj1.tags.all(return_key_and_category=True), [("testing", "testing_category")]
|
||||
)
|
||||
# adding a new tag with no category should create a tag+None entry
|
||||
self.obj1.tags.add("testing")
|
||||
self.assertEqual(
|
||||
self.obj1.tags.all(return_key_and_category=True),
|
||||
[("testing", "testing_category"), ("testing", None)],
|
||||
)
|
||||
|
||||
|
||||
class TestNickHandler(BaseEvenniaTest):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue