Skip to content

Commit ddaedf9

Browse files
Tariq DaoudaTariq Daouda
Tariq Daouda
authored and
Tariq Daouda
committed
added sefault setting on field access
1 parent 71555df commit ddaedf9

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

CHANGELOG.rst

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2.1.1
2+
=====
3+
* Added missing fields value settings on getitem
4+
5+
=====
6+
17
2.1.0
28
=====
39
* Added getitem for documents at the database level

pyArango/document.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,15 @@ def __getitem__(self, field):
151151
if self.collection._validation['allow_foreign_fields'] or self.collection.hasField(field):
152152
return self.store.get(field)
153153

154+
if not field in self.validators:
155+
raise SchemaViolation(self.collection.__class__, field)
156+
154157
try:
155158
return self.store[field]
156159
except KeyError:
157-
raise SchemaViolation(self.collection.__class__, field)
158-
160+
self.store[field] = self.validators[field].default
161+
return self.store[field]
162+
159163
def __setitem__(self, field, value):
160164
"""Set an element in the store"""
161165
if self.mustValidate and (not self.collection._validation['allow_foreign_fields']) and (field not in self.validators) and (field not in self.collection.arangoPrivates):

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
setup(
1212
name='pyArango',
1313

14-
version='2.1.0',
14+
version='2.1.1',
1515

1616
description='An easy to use python driver for ArangoDB with built-in validation',
1717
long_description=long_description,

0 commit comments

Comments
 (0)