Esempio n. 1
0
 def send(self) -> Tree:
     visitor = AbstractSyntaxTreeVisitor([])
     wait_for(visitor.visit_child(self))
     if self._to_json:
         r = wait_for(materialize_walk(visitor.root))
     else:
         r = wait_for(materialize_walk_obj(visitor.root))
     if not self._as_list and not self._as_dict:
         return r
     # r is a list of dicts, but static checkers don't know that
     r = next(itertools.islice(r[0].values(), 0, 1))
     if self._as_dict:
         return {k: v for k, v in zip(self.get_keys(), r)}
     else:
         return r
Esempio n. 2
0
def resolve_field(val):
    try:
        if callable(val):
            val = val()
        if iscoroutinefunction(val):
            return wait_for(val)
        else:
            return val
    except Exception as ex:
        log_exception()
        return None
Esempio n. 3
0
 def to_sql(self) -> str:
     visitor = SQLBuilderVisitor([])
     wait_for(visitor.visit(self))
     return visitor.sql
Esempio n. 4
0
 def dump(self) -> str:
     visitor = PrintASTVisitor([])
     wait_for(visitor.visit(self))
     return visitor.tree
Esempio n. 5
0
 def debug(self, indent=1):
     visitor = AbstractSyntaxTreeVisitor([])
     wait_for(visitor.visit_child(self))
     print_walk(visitor.root, indent)