adding constant handler for comaptibality of pql with python versions > 3.7 #32
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 Python ast module, which this library depends on has been changed in more recent versions of Python. For sure 3.8, and possibly 3.7 or earlier. The ast parser assigns a value of "Constant" to quoted strings and constant numeric values to the right and left side of the comparison operator inside a comparison expression. When this is not handled by the resolve() function inside a AstHandler class as the string "Constant" is appended to "handle_" and then the getattr() method fails because none of the field handler functions have a handle_Constant() function.
So i have added the handle_Constant() function inside a ConstantField class and pass this class as argument inside GenericField class. This handle_constant () function converts constants into a string.
So with this we are able to convert python expression to a pymongo expression even with python versions greater than 3.7