Skip to content

Commit

Permalink
fix bug with redis function hmget
Browse files Browse the repository at this point in the history
  • Loading branch information
tim.reichard committed Feb 18, 2021
1 parent 32e21f0 commit 8a43071
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ History
=======


v0.11.1 (2021-02-18)
-----------------------

* Fix issue with sending None values in redis func hmget.


v0.11.0 (2021-02-18)
-----------------------

Expand Down
9 changes: 5 additions & 4 deletions aioradio/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,10 @@ async def hmget(self, key: str, fields: List[str], use_json: bool=None, encoding

items = {}
for index, value in enumerate(await self.pool.hmget(key, *fields, encoding=encoding)):
if value is not None and use_json:
value = orjson.loads(value)
items[fields[index]] = value
if value is not None:
if use_json:
value = orjson.loads(value)
items[fields[index]] = value

return items

Expand Down Expand Up @@ -237,7 +238,7 @@ async def hset(self, key: str, field: str, value: str, use_json: bool=None, expi
if use_json:
value = orjson.dumps(value)

result = await self.pool.hmset(key, field, value)
result = await self.pool.hset(key, field, value)
await self.pool.expire(key, timeout=expire)

return result
Expand Down
2 changes: 1 addition & 1 deletion aioradio/tests/redis_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async def test_hash_redis_functions(cache):
assert result == 1

result = await cache.hmget(key='complex_hash', fields=['name', 'team', 'apps', 'fake'])
assert result['fake'] is None
assert 'fake' not in result
assert 'aioradio' in result['apps']

result = await cache.hgetall(key='complex_hash')
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
long_description = fileobj.read()

setup(name='aioradio',
version='0.11.0',
version='0.11.1',
description='Generic asynchronous i/o python utilities for AWS services (SQS, S3, DynamoDB, Secrets Manager), Redis, MSSQL (pyodbc), JIRA and more',
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 8a43071

Please sign in to comment.