'Change join types so that the generated query is as efficient as
possible, but still correct. So, change as many joins as possible
to INNER, but don\'t make OUTER joins INNER if that could remove
results from the query.'

def update_join_types(self, query):

    to_promote = set()
    to_demote = set()
    for (table, votes) in self.votes.items():
        if ((self.effective_connector == 'OR') and (votes < self.num_children)):
            to_promote.add(table)
        if ((self.effective_connector == 'AND') or ((self.effective_connector == 'OR') and (votes == self.num_children))):
            to_demote.add(table)
    query.promote_joins(to_promote)
    query.demote_joins(to_demote)
    return to_demote
