Merge pull request #344 from matchbox/complex-change-tracking
Remove custom change tracking for ComplexBaseFields just use BaseField's one
This commit is contained in:
commit
3b60adc8da
@ -205,12 +205,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.
|
||||||
"""
|
"""
|
||||||
|
@ -880,6 +880,27 @@ class FieldTest(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertRaises(ValidationError, e.save)
|
self.assertRaises(ValidationError, e.save)
|
||||||
|
|
||||||
|
def test_complex_field_same_value_not_changed(self):
|
||||||
|
"""
|
||||||
|
If a complex field is set to the same value, it should not be marked as
|
||||||
|
changed.
|
||||||
|
"""
|
||||||
|
class Simple(Document):
|
||||||
|
mapping = ListField()
|
||||||
|
|
||||||
|
Simple.drop_collection()
|
||||||
|
e = Simple().save()
|
||||||
|
e.mapping = []
|
||||||
|
self.assertEqual([], e._changed_fields)
|
||||||
|
|
||||||
|
class Simple(Document):
|
||||||
|
mapping = DictField()
|
||||||
|
|
||||||
|
Simple.drop_collection()
|
||||||
|
e = Simple().save()
|
||||||
|
e.mapping = {}
|
||||||
|
self.assertEqual([], e._changed_fields)
|
||||||
|
|
||||||
def test_list_field_complex(self):
|
def test_list_field_complex(self):
|
||||||
"""Ensure that the list fields can handle the complex types."""
|
"""Ensure that the list fields can handle the complex types."""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user