Fixed inconsistency handling None values field attrs
fixes hmarr/mongoengine#505
This commit is contained in:
@@ -833,13 +833,6 @@ class BaseDocument(object):
|
||||
if hasattr(self, '_changed_fields'):
|
||||
self._mark_as_changed(name)
|
||||
|
||||
# Handle None values for required fields
|
||||
if value is None and name in getattr(self, '_fields', {}):
|
||||
self._data[name] = value
|
||||
if hasattr(self, '_changed_fields'):
|
||||
self._mark_as_changed(name)
|
||||
return
|
||||
|
||||
if not self._created and name in self._meta.get('shard_key', tuple()):
|
||||
from queryset import OperationError
|
||||
raise OperationError("Shard Keys are immutable. Tried to update %s" % name)
|
||||
|
||||
@@ -369,7 +369,7 @@ class ComplexDateTimeField(StringField):
|
||||
return self._convert_from_string(data)
|
||||
|
||||
def __set__(self, instance, value):
|
||||
value = self._convert_from_datetime(value)
|
||||
value = self._convert_from_datetime(value) if value else value
|
||||
return super(ComplexDateTimeField, self).__set__(instance, value)
|
||||
|
||||
def validate(self, value):
|
||||
|
||||
Reference in New Issue
Block a user