only mark a field as changed if the value has changed
Prevents spurious changes from being recorded.
This commit is contained in:
parent
9f58bc9207
commit
faf840f924
1
AUTHORS
1
AUTHORS
@ -128,3 +128,4 @@ that much better:
|
|||||||
* Peter Teichman
|
* Peter Teichman
|
||||||
* Jakub Kot
|
* Jakub Kot
|
||||||
* Jorge Bastida
|
* Jorge Bastida
|
||||||
|
* Paul Swartz
|
@ -205,8 +205,12 @@ class BaseField(object):
|
|||||||
def __set__(self, instance, value):
|
def __set__(self, instance, value):
|
||||||
"""Descriptor for assigning a value to a field in a document.
|
"""Descriptor for assigning a value to a field in a document.
|
||||||
"""
|
"""
|
||||||
instance._data[self.name] = value
|
changed = False
|
||||||
if instance._initialised:
|
if (self.name not in instance._data or
|
||||||
|
instance._data[self.name] != value):
|
||||||
|
changed = True
|
||||||
|
instance._data[self.name] = value
|
||||||
|
if changed and instance._initialised:
|
||||||
instance._mark_as_changed(self.name)
|
instance._mark_as_changed(self.name)
|
||||||
|
|
||||||
def error(self, message="", errors=None, field_name=None):
|
def error(self, message="", errors=None, field_name=None):
|
||||||
@ -317,12 +321,6 @@ class ComplexBaseField(BaseField):
|
|||||||
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def __set__(self, instance, value):
|
|
||||||
"""Descriptor for assigning a value to a field in a document.
|
|
||||||
"""
|
|
||||||
instance._data[self.name] = value
|
|
||||||
instance._mark_as_changed(self.name)
|
|
||||||
|
|
||||||
def to_python(self, value):
|
def to_python(self, value):
|
||||||
"""Convert a MongoDB-compatible type to a Python type.
|
"""Convert a MongoDB-compatible type to a Python type.
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user