diff --git a/HISTORY.rst b/HISTORY.rst index 7212843..76801f5 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -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) ----------------------- diff --git a/aioradio/redis.py b/aioradio/redis.py index 009d3d1..f1fa120 100644 --- a/aioradio/redis.py +++ b/aioradio/redis.py @@ -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 @@ -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 diff --git a/aioradio/tests/redis_test.py b/aioradio/tests/redis_test.py index 768fbd1..23d04e7 100644 --- a/aioradio/tests/redis_test.py +++ b/aioradio/tests/redis_test.py @@ -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') diff --git a/setup.py b/setup.py index e41bf52..d364a8f 100644 --- a/setup.py +++ b/setup.py @@ -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",