

def get_bare_select(self, columns=None):
    if (columns is None):
        columns = self.get_fields()
    s = select(columns)
    if self.joins:
        full_join = None
        for j in self.joins:
            if (full_join is not None):
                full_join = full_join.join(*j)
            else:
                full_join = outerjoin(self.table, *j)
        s = self.select_from(full_join)
    if (self.condition is not None):
        s = s.where(self.condition)
    if self.joins:
        if self.group_bys:
            my_group_bys = self.group_bys[:]
        else:
            my_group_bys = []
        for column in columns:
            if ((not (column in my_group_bys)) and (not isinstance(column, SqlFunction))):
                my_group_bys.append(column)
    else:
        my_group_bys = self.group_bys
    if my_group_bys:
        s = s.group_by(*my_group_bys)
    if self.havings:
        for having in self.havings:
            s = s.having(having)
    if self._limit:
        s = s.limit(self._limit)
    if self._offset:
        s = s.offset(self._offset)
    if self.order_bys:
        order_bys = []
        for (key, direction) in self.order_bys:
            try:
                order_bys.append(direction(self.table.c[self.backend.get_column_for_key(self.cls, key)]))
            except KeyError:
                continue
            s = s.order_by(*order_bys)
    return s

dataset/ETHPy150Open adewes/blitzdb/blitzdb/backends/sql/queryset.py QuerySet.get_bare_select/VarMisuse@100/123 `s`->`self`