Skip to content

Commit

Permalink
support null values for optional int, float fields on save method
Browse files Browse the repository at this point in the history
Signed-off-by: wiseaidev <business@wiseai.dev>
  • Loading branch information
wiseaidev committed Aug 9, 2022
1 parent 2b74294 commit 1efdbdf
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions aredis_om/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,8 @@ async def save(self, pipeline: Optional[Pipeline] = None) -> "HashModel":
db = pipeline
document = jsonable_encoder(self.dict())
# TODO: Wrap any Redis response errors in a custom exception?
# store null values as string zero: "0"
document = {key: val if val else "0" for key, val in document.items()}
await db.hset(self.key(), mapping=document)
return self

Expand Down

0 comments on commit 1efdbdf

Please sign in to comment.