Skip to content

Commit

Permalink
fix mongo visitor parser
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaiarocci committed Jan 14, 2018
1 parent 6d1526b commit f8f7019
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions eve/io/mongo/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,19 @@ def visit_Call(self, node):
datetime().
"""
if isinstance(node.func, ast.Name):
expr = None
if node.func.id == 'ObjectId':
expr = "('" + node.args[0].s + "')"
try:
self.current_value = ObjectId(node.args[0].s)
except:
pass
elif node.func.id == 'datetime':
values = []
for arg in node.args:
values.append(str(arg.n))
expr = "(" + ", ".join(values) + ")"
if expr:
self.current_value = eval(node.func.id + expr)
values.append(arg.n)
try:
self.current_value = datetime(*values)
except:
pass

def visit_Attribute(self, node):
""" Attribute handler ('Contact.Id').
Expand Down

0 comments on commit f8f7019

Please # to comment.