Skip to content

Commit

Permalink
feat: add support for empty in_obj in update method
Browse files Browse the repository at this point in the history
  • Loading branch information
e-kondr01 committed Oct 10, 2023
1 parent 842dd33 commit c015dd6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[FORMAT]
max-line-length=88

[MESSAGES CONTROL]
disable=missing-docstring,too-few-public-methods,no-name-in-module,no-member,too-many-ancestors
6 changes: 4 additions & 2 deletions fastapi_sqlalchemy_toolkit/model_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ async def update(
self,
session: AsyncSession,
db_obj: ModelType,
in_obj: UpdateSchemaType | ModelDict,
in_obj: UpdateSchemaType | ModelDict | None = None,
refresh_attribute_names: Iterable[str] | None = None,
commit: bool = True,
**attrs: Any,
Expand All @@ -518,7 +518,9 @@ async def update(
:returns: обновлённый экземпляр модели
"""
if isinstance(in_obj, dict):
if in_obj is None:
in_obj = {}
elif isinstance(in_obj, dict):
update_data = in_obj
else:
update_data = in_obj.model_dump()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "fastapi_sqlalchemy_toolkit"
version = "0.4.1"
version = "0.4.2"
authors = [
{ name="Egor Kondrashov", email="[email protected]" },
]
Expand Down

0 comments on commit c015dd6

Please sign in to comment.