def visit_order(self, node): # if there is no specific ordering, then order by id if not node.value: return [ qlast.SortExpr( path=qlast.Path( steps=[qlast.Ptr(ptr=qlast.ObjectRef(name='id'))], partial=True, ), direction=qlast.SortAsc, ) ] # Ordering is handled by specifying a list of special Ordering objects. # Validation is already handled by this point. orderby = [] for enum in node.value: name, direction, nulls = self._visit_order_item(enum) orderby.append( qlast.SortExpr( path=qlast.Path( steps=[qlast.Ptr(ptr=qlast.ObjectRef(name=name))], partial=True, ), direction=direction, nones_order=nulls, )) return orderby
def visit_SortExpr(self, node): result = qlast.SortExpr( path=self.visit(node.expr), direction=node.direction, nones_order=node.nones_order ) return result
def reduce_Expr_OptDirection_OptNonesOrder(self, *kids): self.val = qlast.SortExpr(path=kids[0].val, direction=kids[1].val, nones_order=kids[2].val)