Closed thekie closed 5 years ago
Merging #117 into master will increase coverage by
0.27%
. The diff coverage is97.43%
.
@@ Coverage Diff @@
## master #117 +/- ##
==========================================
+ Coverage 80.01% 80.28% +0.27%
==========================================
Files 12 12
Lines 2117 2141 +24
==========================================
+ Hits 1694 1719 +25
+ Misses 423 422 -1
Impacted Files | Coverage Δ | |
---|---|---|
pyArango/document.py | 74.37% <100%> (+0.71%) |
:arrow_up: |
pyArango/tests/tests.py | 97.67% <97.29%> (-0.09%) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 3d91c08...b09fa4a. Read the comment docs.
Thank you for this great PR. Very well explained and tested. Amazing work.
Thank you! My pleasure @tariqdaouda!
The problem for me was that pyArango implicitly expects nested fields to be validated as well. In the
DocumentStore
you find the following lines in theset()
and__setitem__
methods:These lines check if the current value of the field is a dictionary and if that is the case, the validators of this fields are redirected into the sup
DataStore
. This is problematic if your field definition looks like this:If you now set
nested_something
to a some nested data, the value of theField
nested_something
is adict
and the validatorsvals
(from the code snippet above) has the value of aField
object. Unfortunately, theDataStore
expects to get a dictionary mapping field name toField
object, which results in the error message.This code makes perfect sense if your field definition looks like this:
In this case, the value of the validators
vals
, which get into theDataStore
is a dictionary mapping field name toField
object and the nested fields are getting validated as expected. But in our definition 1, we don't want to validate the subfields.So the fix is to check if the field definition is actually a dict to and only then redirect the validators to the sub
DataStore
.This way the validation runs as expected and if you allow
allow_foreign_fields
for yourCollection
you can use arbitrary nested data.