Skip to content

Commit

Permalink
Allow null values in patch endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasKs committed Apr 11, 2022
1 parent dc70a26 commit 3812288
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/api/api_v2/endpoints/video/patch_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
class VideoPatch(BaseModel):
path: str
display_name: Optional[str] = Field(default=None, regex=r'^[\s\w\d_-]*$', min_length=2, max_length=40)
hidden: bool = Field(default=False)
tags: list[TagBase] = Field(default=[])
hidden: Optional[bool] = Field(default=None)
tags: Optional[list[TagBase]] = Field(default=None)


@router.patch('/files', response_model=VideoRead)
Expand All @@ -32,6 +32,8 @@ async def patch_video(
Partially update a video.
"""
excluded = video_patch.dict(exclude_unset=True)
[excluded.pop(x) for x in [key for key, value in excluded.items() if value is None]]

query_video = (
select(Video)
.where(and_(Video.path == video_patch.path, Video.user_id == user.id))
Expand Down

0 comments on commit 3812288

Please sign in to comment.