Skip to content

Commit

Permalink
Removing relation child while updating nullable fk as None
Browse files Browse the repository at this point in the history
  • Loading branch information
amit12297 committed Nov 24, 2023
1 parent 11b3e85 commit 7c2954d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ormar/models/descriptors/descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ def __set__(self, instance: "Model", value: Any) -> None:
else:
# foreign key relation
instance.__dict__[self.name] = model
if value is None and instance.Meta.model_fields[self.name].nullable:
instance._orm.remove(self.name, getattr(instance, self.name))
instance.set_save_status(False)


Expand Down

0 comments on commit 7c2954d

Please sign in to comment.