'Do any necessary class setup immediately prior to producing SQL. This
is for things that can\'t necessarily be done in __init__ because we
might not have all the pieces in place at that time.'

def pre_sql_setup(self):

    self.setup_query()
    order_by = self.get_order_by()
    (self.where, self.having) = self.query.where.split_having()
    extra_select = self.get_extra_select(order_by, self.select)
    self.has_extra_select = bool(extra_select)
    group_by = self.get_group_by((self.select + extra_select), order_by)
    return (extra_select, order_by, group_by)
