def _as_sql(self): best_agg = self.cuboid._find_best_agg(self.parts) query = self._adapt(best_agg) things = query.parts selects = [sel for t in things for sel in t._as_selects(best_agg)] query = sql_select([], from_obj=query.cuboid.selectable) return compile(selects, query, best_agg)
def members_query(self): return sql_select([self._id_column.label('id'), self._label_column.label('label')])