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