-
-
Notifications
You must be signed in to change notification settings - Fork 744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix a serialization bug that randomly skips fields if "x_of" is encountered #1042
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nicolaiarocci
requested changes
Aug 8, 2017
eve/tests/methods/common.py
Outdated
@@ -1,4 +1,5 @@ | |||
import time | |||
from collections import OrderedDict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line fails on Python 2.6. Please replace it with:
try:
from collections import OrderedDict # noqa
except ImportError:
# Python 2.6 needs this back-port
from ordereddict import OrderedDict
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, didn't know of that, thanks. I have updated the commit, please have a look.
nicolaiarocci
approved these changes
Aug 9, 2017
Thanks! |
Amedeo91
pushed a commit
to Amedeo91/eve
that referenced
this pull request
Aug 11, 2017
Amedeo91
pushed a commit
to Amedeo91/eve
that referenced
this pull request
Aug 11, 2017
Amedeo91
pushed a commit
to Amedeo91/eve
that referenced
this pull request
Aug 11, 2017
Amedeo91
pushed a commit
to Amedeo91/eve
that referenced
this pull request
Aug 11, 2017
lexhung
added a commit
to lexhung/eve
that referenced
this pull request
Nov 1, 2017
* 'master' of https://github.com/pyeve/eve: (374 commits) Changelog for pyeve#1070 use OrderedDict from backport_collections Minor changelog fixes for pyeve#1048 Support Decimal type MongoDB Changelog: add reference to proper PR Changelog update for pyeve#1042 Fix a serialization bug that randomly skips fields if "x_of" is encountered Amedeo Bussi Changelog for pyeve#1030 pep/flake, and remove duplicate test documentation improvements and fixes Bulk delete MONGO_DBNAME can be now used along with MONGO_URI Vasilis Lolis typo Amedeo91 Changelog for pyeve#1031 Bulk Embedded document resolution Delete unnecessary code Fix insidious bug in tests.TestPost class ...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The purpose of this PR is to make sure all of the fields are correctly serialized when there are
x_of
validation rules.The tricky part of this bug is that it is not stably repeatable. This is because the serialization iterates through the json keys in random order, and the bug shows up only when the fields that contain
x_of
rules are processed before other fields. In short, theschema
variable in functionserialize
will be overwritten mistakenly inif x_of
clause, causing the serialization of the rest of the fields are skipped, due to the ill-formedschema
.Along with this bug fix, the PR also enabled correct serialization under circumstances where
x_of
appears at the first level of a field's schema whose type is list.Two new unit test cases are written for these scenarios, and one of them uses
OrderedDict
to guarantee the traversing order of the json keys.(This is a repost of PR #1040. Please let me know if there are other improvements I need to make.)