Merge pull request #74 from heyyyoyy/dev-2.x

Fixed update_data and update_bucket methods if dict is None
This commit is contained in:
Alex Root Junior 2018-09-03 00:58:24 +03:00 committed by GitHub
commit 61f3e3c8a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -141,6 +141,8 @@ class RedisStorage(BaseStorage):
async def update_data(self, *, chat: typing.Union[str, int, None] = None, user: typing.Union[str, int, None] = None,
data: typing.Dict = None, **kwargs):
if data is None:
data = {}
record = await self.get_record(chat=chat, user=user)
record_data = record.get('data', {})
record_data.update(data, **kwargs)
@ -195,6 +197,8 @@ class RedisStorage(BaseStorage):
bucket: typing.Dict = None, **kwargs):
record = await self.get_record(chat=chat, user=user)
record_bucket = record.get('bucket', {})
if bucket is None:
bucket = {}
record_bucket.update(bucket, **kwargs)
await self.set_record(chat=chat, user=user, state=record['state'], data=record_bucket, bucket=bucket)