def _get_base_sql_ast(self, modifier=None, entities=None):
    entities = (self._entities if (entities is None) else entities)
    if self._join_chain:
        table_section = self._join_chain.get_sql_ast()
    else:
        table_section = ['TABLE', self.table_name]
    contains_distinct = any((isinstance(entity, DISTINCT) for entity in entities))
    if (contains_distinct and self._order_by):
        for ob in self._order_by:
            if (not self._entities_contains(ob.value)):
                entities = (entities + [ob.value])
    select_ast = (['SERIES'] + [(e.get_sql_ast() if hasattr(e, 'get_sql_ast') else e) for e in entities])
    if ((len(select_ast) == 2) and (select_ast[1][0] == 'SERIES')):
        select_ast = select_ast[1]
    if (modifier is not None):
        select_ast = ['MODIFIER', modifier, select_ast]
    return ['SELECT', select_ast, ['FROM', table_section]]
def _get_base_sql_ast(self, modifier=None, entities=None):
    entities = (self._entities if (entities is None) else entities)
    if self._join_chain:
        table_section = self._join_chain.get_sql_ast()
    else:
        table_section = ['TABLE', self.table_name]
    contains_distinct = any((isinstance(entity, DISTINCT) for entity in entities))
    if (contains_distinct and self._order_by):
        for ob in self._order_by:
            if (not self._entities_contains(ob.value)):
                entities = (entities + [ob.value])
    select_ast = (['SERIES'] + [(e.get_sql_ast() if hasattr(e, 'get_sql_ast') else e) for e in entities])
    if ((len(select_ast) == 2) and (select_ast[1][0] == 'SERIES')):
        select_ast = select_ast[1]
    if (modifier is not None):
        select_ast = ['MODIFIER', modifier, select_ast]
    return ['SELECT', select_ast, ['FROM', table_section]]