Repository navigation
Improve field validation for documents - #769
Conversation
pcorpet
left a comment
There was a problem hiding this comment.
Thanks a lot for your contribution.
Please add a test that illustrates that recent versions accept weirder names.
|
|
||
| recursive_none_key_check(data) | ||
| for key in data.keys(): | ||
| if len(key) > 0 and key[0] == "$": |
There was a problem hiding this comment.
Forgot about that one, thanks!
|
|
||
|
|
||
| def _validate_data_fields(data): | ||
| def recursive_none_key_check(data): |
There was a problem hiding this comment.
This function isn't using any closure, so I'd rather not have it as a nested function
There was a problem hiding this comment.
Moved it out of the function
| def _validate_data_fields(data): | ||
| def recursive_none_key_check(data): | ||
| for key, value in data.items(): | ||
| if "\0" in key: |
There was a problem hiding this comment.
Please use single quotes for literal strings. '\0' (same in all your changes).
There was a problem hiding this comment.
Changed to using all single quotes
9ce81d5 to
32f9fa1
Compare
Codecov Report
@@ Coverage Diff @@
## develop #769 +/- ##
===========================================
+ Coverage 95.22% 95.25% +0.03%
===========================================
Files 20 20
Lines 3790 3815 +25
===========================================
+ Hits 3609 3634 +25
Misses 181 181
Continue to review full report at Codecov.
|
0cb98b0 to
8b63fd5
Compare
8b63fd5 to
bc7544b
Compare
|
Hi @pcorpet, wondering if you have the time for a second review. I made sure to add your suggested changes! |
|
This would be a great one so the mocking gets closer to the validation of the actual mongo. Any updates on getting this one merged? |
|
Thanks for pinging folks, it's working. I'll take a look now. |
Starting from mongodb 3.6 field names cannot contain the null character and top-field names cannot start with the dollar sign. Apart form those cases mongodb does permit storage of the dots and dollar signs (mongodb v3.6). Newer versions of mongodb add improved support (mongodb v4.0, mongodb v5.0).
Fixes: #720