Fix issues with integer tag names on postgres. Resolve #3624

This commit is contained in:
Griatch 2024-09-29 11:48:02 +02:00
parent 6afe37631f
commit ac06ff735c
3 changed files with 11 additions and 5 deletions

View file

@ -34,6 +34,7 @@ did not add it to the handler's object (Griatch)
(aMiss-aWry)
- [Fix][issue3612]: Make sure help entries' `subtopic_separator_char` is
respected (Griatch)
- [Fix][issue3624]: Setting tags with integer names caused errors on postgres (Griatch)
- [Docs][issue3591]: Fix of NPC reaction tutorial code (Griatch)
- Docs: Tutorial fixes (Griatch, aMiss-aWry, feyrkh)
@ -42,6 +43,7 @@ did not add it to the handler's object (Griatch)
[issue3556]: https://github.com/evennia/evennia/issues/3556
[issue3519]: https://github.com/evennia/evennia/issues/3519
[issue3612]: https://github.com/evennia/evennia/issues/3612
[issue3624]: https://github.com/evennia/evennia/issues/3624
[pull3595]: https://github.com/evennia/evennia/pull/3595
[pull3533]: https://github.com/evennia/evennia/pull/3533
[pull3594]: https://github.com/evennia/evennia/pull/3594

View file

@ -627,6 +627,7 @@ def search_prototype(
if key:
# exact or partial match on key
key = str(key).strip().lower()
exact_match = query.filter(Q(db_key__iexact=key))
if not exact_match and fuzzy_matching:
# try with partial match instead

View file

@ -14,7 +14,6 @@ from collections import defaultdict
from django.conf import settings
from django.db import models
from evennia.locks.lockfuncs import perm as perm_lockfunc
from evennia.utils.utils import make_iter, to_str
@ -592,8 +591,10 @@ class TagHandler(object):
"""
ret = []
category = category.strip().lower() if category is not None else None
for keystr in make_iter(key):
# note - the _getcache call removes case sensitivity for us
keystr = str(keystr).strip().lower()
ret.extend(
[
tag if return_tagobj else to_str(tag.db_key)
@ -632,7 +633,7 @@ class TagHandler(object):
if not (key or key.strip()): # we don't allow empty tags
continue
tagstr = str(key).strip().lower()
category = category.strip().lower() if category else category
category = str(category).strip().lower() if category else category
# This does not delete the tag object itself. Maybe it should do
# that when no objects reference the tag anymore (but how to check)?
@ -662,7 +663,7 @@ class TagHandler(object):
"tag__db_tagtype": self._tagtype,
}
if category:
query["tag__db_category"] = category.strip().lower()
query["tag__db_category"] = str(category).strip().lower()
getattr(self.obj, self._m2m_fieldname).through.objects.filter(**query).delete()
self._cache = {}
self._catcache = {}
@ -727,7 +728,7 @@ class TagHandler(object):
keys[tup[1]].append(tup[0])
data[tup[1]] = tup[2] # overwrite previous
for category, key in keys.items():
self.add(key=key, category=category, data=data.get(category, None))
self.add(key=str(key).strip().lower(), category=category, data=data.get(category, None))
def batch_remove(self, *args):
"""
@ -748,7 +749,9 @@ class TagHandler(object):
elif nlen > 1:
keys[tup[1]].append(tup[0])
for category, key in keys.items():
self.remove(key=key, category=category, data=data.get(category, None))
self.remove(
key=str(key).strip().lower(), category=category, data=data.get(category, None)
)
def __str__(self):
return ",".join(self.all())