Skip to content

Commit

Permalink
[#351] Only apply merge on partial updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed Dec 27, 2023
1 parent ab5ef67 commit cdeb100
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/objects/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,12 @@ def update(self, instance, validated_data):
# object_data is not used since all object attributes are immutable
object_data = validated_data.pop("object", None)
validated_data["object"] = instance.object
# in case of PATCH
# version should be set
if "version" not in validated_data:
validated_data["version"] = instance.version
if "data" in validated_data:
# Apply JSON Merge Patch for record data
validated_data["data"] = merge_patch(
instance.data, validated_data["data"]
)
if self.partial and "data" in validated_data:
# Apply JSON Merge Patch for record data
validated_data["data"] = merge_patch(instance.data, validated_data["data"])

record = super().create(validated_data)
return record
Expand Down

0 comments on commit cdeb100

Please sign in to comment.