From cdeb1000faec86e572a24f2d71770b20ad199961 Mon Sep 17 00:00:00 2001 From: Viicos <65306057+Viicos@users.noreply.github.com> Date: Wed, 27 Dec 2023 12:08:48 +0100 Subject: [PATCH] [#351] Only apply merge on partial updates --- src/objects/api/serializers.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/objects/api/serializers.py b/src/objects/api/serializers.py index 4b21a948..4e7cc4b4 100644 --- a/src/objects/api/serializers.py +++ b/src/objects/api/serializers.py @@ -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