diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5a484b1..286fab9 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,9 @@ +2.1.1 +===== +* Added missing fields value settings on getitem + +===== + 2.1.0 ===== * Added getitem for documents at the database level diff --git a/pyArango/document.py b/pyArango/document.py index 7ef03c8..9391a24 100644 --- a/pyArango/document.py +++ b/pyArango/document.py @@ -151,11 +151,15 @@ def __getitem__(self, field): if self.collection._validation['allow_foreign_fields'] or self.collection.hasField(field): return self.store.get(field) + if not field in self.validators: + raise SchemaViolation(self.collection.__class__, field) + try: return self.store[field] except KeyError: - raise SchemaViolation(self.collection.__class__, field) - + self.store[field] = self.validators[field].default + return self.store[field] + def __setitem__(self, field, value): """Set an element in the store""" if self.mustValidate and (not self.collection._validation['allow_foreign_fields']) and (field not in self.validators) and (field not in self.collection.arangoPrivates): diff --git a/setup.py b/setup.py index 5cddccf..88d977e 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ setup( name='pyArango', - version='2.1.0', + version='2.1.1', description='An easy to use python driver for ArangoDB with built-in validation', long_description=long_description,