Skip to content

Commit

Permalink
allow updating values to None/empty when field is not required
Browse files Browse the repository at this point in the history
  • Loading branch information
douwevandermeij committed Aug 5, 2024
1 parent 7f85101 commit 8cbe253
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fractal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Fractal is a scaffolding toolkit for building SOLID logic for your Python applications."""

__version__ = "5.0.0"
__version__ = "5.0.1"

from abc import ABC

Expand Down
6 changes: 5 additions & 1 deletion fractal/contrib/fastapi/routers/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ def update_entity(
):
if _entity := self.get_entity(entity_id, specification=specification, **kwargs):
_entity = _entity.update(
{k: v for k, v in contract.dict().items() if v is not None}
{
k: v
for k, v in contract.dict().items()
if (contract.model_fields[k].is_required() and v) or True
}
)
else:
_entity = contract.to_entity(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "fractal-toolkit"
version = "5.0.0"
version = "5.0.1"
description = "Fractal is a scaffolding toolkit for building SOLID logic for your Python applications."
authors = ["Douwe van der Meij <douwe@karibu-online.nl>"]

Expand Down

0 comments on commit 8cbe253

Please sign in to comment.