pql
pql copied to clipboard
adding constant handler for comaptibality of pql with python versions > 3.7
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