- Mongo Filter Evaluator version: 1.0
- Python version: 2.7.4
- Operating System: Centos7
Description
d = {... any data will do ...}
f = {"$and": [{any first filter}, {}]
DataConditionEvaluator(f,d).evaluate()
Leads to stack overrun...recursive calls.
Describe what you were trying to get done.
In the automated building for filter conditions it is common to use a {} empty filter when one part of the generation does not apply vs. simply removing the filter from the $and condition itself. This way one can see that a filter was returned for that part of the and however, it was a empty filter which should pass. Thus the $and logic remains syntactically correct. For example, a user supplied filter on the left and a entitlement filter on the right. If the user is entitled to see everything then syntactically a {} may be used as a replacement.
Tell us what happened, what went wrong, and what you expected to happen.
Exception RuntimeError: maximum recursion depth exceeded
What I Did
Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
def test_filter_stream_and2e(self):
f = {'$and': [{'blah': 0.3}, {}]}
d = {u'blah': 0.3}
DataConditionEvaluator(f, d).evaluate()
File "/usr/lib/python2.7/site-packages/mongo_filter_evaluator/base.py", line 52, in c_and
for condition in body
File "/usr/lib/python2.7/site-packages/mongo_filter_evaluator/base.py", line 52, in
for condition in body
File "/usr/lib/python2.7/site-packages/mongo_filter_evaluator/base.py", line 27, in evaluate
return self.evaluate_logic('$and', condition)
File "/usr/lib/python2.7/site-packages/mongo_filter_evaluator/evaluator.py", line 98, in evaluate_logic
return getattr(self, 'c_%s' % keyword[1:])(body)
File "/usr/lib/python2.7/site-packages/mongo_filter_evaluator/base.py", line 47, in c_and
for (condition_keyword, condition_body) in body.items()
File "/usr/lib/python2.7/site-packages/mongo_filter_evaluator/base.py", line 47, in
for (condition_keyword, condition_body) in body.items()
File "/usr/lib/python2.7/site-packages/mongo_filter_evaluator/base.py", line 36, in evaluate_condition
for op_keyword, op_body in body.items()
File "/usr/lib/python2.7/site-packages/mongo_filter_evaluator/base.py", line 36, in
for op_keyword, op_body in body.items()
File "/usr/lib/python2.7/site-packages/mongo_filter_evaluator/evaluator.py", line 103, in evaluate_function
value=body,
File "/usr/lib/python2.7/site-packages/mongo_filter_evaluator/evaluator.py", line 13, in wrap_method
return (field in self.data) and f(self, field, value)
RuntimeError: maximum recursion depth exceeded