Skip to content

Conversation

@maennel
Copy link
Contributor

@maennel maennel commented Dec 19, 2016

This PR attempts to fix #1438.
It adds a check of the passed SON value.

If the SON was neither a dict or None, the raised error was an AttributeError, independent of the given value. The error was raised, since the (native) value did not provide a get(..) method.

@wojcikstefan
Copy link
Member

Thanks for this. In my opinion, InvalidQueryError shouldn't be raised in _from_son, which is used for more than just querying. Is there a better place in the querying portion of the code where we can throw this exception before we even call _from_son?

@maennel
Copy link
Contributor Author

maennel commented Dec 20, 2016

Hm, that makes sense. The portion of code that allows for invalid "SON-values" to pass is this one, preparing the query.
I suggest to add the check in there, then. What do you think?

@maennel
Copy link
Contributor Author

maennel commented Dec 21, 2016

@wojcikstefan I've updated the PR. Feel free to have a look at it. Now, _from_son returns a more generic error. On the other side, preparing a query raises an appropriate InvalidQueryError.

@wojcikstefan
Copy link
Member

@maennel this looks great! Thanks for taking the time to address my concerns.

@wojcikstefan wojcikstefan merged commit 9f4b04e into MongoEngine:master Dec 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect error AttributeError raised when querying with wrong type of value

2 participants