Skip to content

Commit

Permalink
fix(relations): save with update_fields
Browse files Browse the repository at this point in the history
When Property's save method is called with
update_fields to update name_forward, make sure
name_reverse is saved as well.
  • Loading branch information
koeaw committed Apr 9, 2024
1 parent f1dd3db commit a9e52c5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apis_core/apis_relations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ def save(self, *args, **kwargs):
self.name_forward = unicodedata.normalize("NFC", str(self.name_forward))
self.name_reverse = unicodedata.normalize("NFC", str(self.name_reverse))

if (update_fields := kwargs.get("update_fields")) is not None:
if "name_forward" in update_fields and "name_reverse" not in update_fields:
modified_update_fields = set(update_fields)
modified_update_fields.add("name_reverse")
kwargs["update_fields"] = modified_update_fields

super(Property, self).save(*args, **kwargs)
return self

Expand Down

0 comments on commit a9e52c5

Please sign in to comment.