do not validate default values in validate_and_update
@@ -758,18 +758,14 @@ class Table(Serializable, BasicStorage):
def _validate_fields(self, fields, defattr='default'):
response = Row()
- response.id, response.errors = None, Row()
- new_fields = copy.copy(fields)
- for fieldname in self.fields:
- default = getattr(self[fieldname], defattr)
- if callable(default):
- default = default()
- raw_value = fields.get(fieldname, default)
- value, error = self[fieldname].validate(raw_value)
+ response.id, response.errors, new_fields = None, Row(), Row()
+ for field in self:
+ if field.name in fields:
+ value, error = field.validate(fields[field.name])
if error:
- response.errors[fieldname] = "%s" % error
- elif value is not None:
- new_fields[fieldname] = value
+ response.errors[field.name] = "%s" % error
+ else:
+ new_fields[field.name] = value
return response, new_fields
def validate_and_insert(self, **fields):
