Skip to content

Commit 28924fa

Browse files
committed
Fix: DictField are always marked as changed
Only triggering `_mark_as_changed` on DictField if the value is actually changed.
1 parent 1790f3d commit 28924fa

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mongoengine/base/datastructures.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ def mark_key_as_changed_wrapper(parent_method):
3131

3232
def wrapper(self, key, *args, **kwargs):
3333
# Can't use super() in the decorator.
34-
result = parent_method(self, key, *args, **kwargs)
35-
self._mark_as_changed(key)
36-
return result
34+
if not args or not key or key not in self or self[key] != args[0]:
35+
self._mark_as_changed(key)
36+
return parent_method(self, key, *args, **kwargs)
3737

3838
return wrapper
3939

0 commit comments

Comments
 (0)