Fix all_pks to work if decode_responses=False

This commit is contained in:
Andrew Brookins 2021-11-08 16:48:43 -08:00
parent c7c6dffe7a
commit 6c8cf0b01d
2 changed files with 5 additions and 2 deletions

View file

@ -1210,8 +1210,11 @@ class HashModel(RedisModel, abc.ABC):
# TODO: We assume the key ends with the default separator, ":" -- when
# we make the separator configurable, we need to update this as well.
# ... And probably lots of other places ...
#
# TODO: Also, we need to decide how we want to handle the lack of
# decode_responses=True...
return (
key.split(":")[-1]
key.split(":")[-1] if isinstance(key, str) else key.decode(cls.Meta.encoding).split(":")[-1]
for key in cls.db().scan_iter(f"{key_prefix}*", _type="HASH")
)