'Merge the \'rhs\' query into the current one (with any \'rhs\' effects
being applied *after* (that is, "to the right of") anything in the
current query. \'rhs\' is not modified during a call to this function.
The \'connector\' parameter describes how to connect filters from the
\'rhs\' query.'

def combine(self, rhs, connector):

    assert (self.model == rhs.model), 'Cannot    combine    queries    on    two    different    base    models.'
    assert self.can_filter(), 'Cannot    combine    queries    once    a    slice    has    been    taken.'
    assert (self.distinct == rhs.distinct), 'Cannot    combine    a    unique    query    with    a    non-unique    query.'
    assert (self.distinct_fields == rhs.distinct_fields), 'Cannot    combine    queries    with    different    distinct    fields.'
    self.remove_inherited_models()
    change_map = {}
    conjunction = (connector == AND)
    reuse = (set() if conjunction else set(self.tables))
    self.get_initial_alias()
    for alias in rhs.tables[1:]:
        (table, _, join_type, lhs, join_cols, nullable, join_field) = rhs.alias_map[alias]
        promote = (join_type == self.LOUTER)
        lhs = change_map.get(lhs, lhs)
        new_alias = self.join((lhs, table, join_cols), reuse=reuse, outer_if_first=(not conjunction), nullable=nullable, join_field=join_field)
        if promote:
            self.promote_joins([new_alias])
        reuse.discard(new_alias)
        change_map[alias] = new_alias
        if (not rhs.alias_refcount[alias]):
            self.unref_alias(new_alias)
    if (not conjunction):
        rhs_used_joins = set(change_map.values())
        to_promote = [alias for alias in self.tables if (alias not in rhs_used_joins)]
        self.promote_joins(to_promote, True)
    if rhs.where:
        w = rhs.where.clone()
        w.relabel_aliases(change_map)
        if (not self.where):
            self.where.add(EverythingNode(), AND)
    elif self.where:
        w = self.where_class()
        w.add(EverythingNode(), AND)
    else:
        w = self.where_class()
    self.where.add(w, connector)
    self.select = []
    for (col, field) in rhs.select:
        if isinstance(col, (list, tuple)):
            new_col = (change_map.get(col[0], col[0]), col[1])
            self.select.append(SelectInfo(new_col, field))
        else:
            new_col = col.relabeled_clone(change_map)
            self.select.append(SelectInfo(new_col, field))
    if (connector == OR):
        if (self.extra and rhs.extra):
            raise ValueError("When    merging    querysets    using    'or',    you    cannot    have    extra(select=...)    on    both    sides.")
    self.extra.update(rhs.extra)
    extra_select_mask = set()
    if (self.extra_select_mask is not None):
        extra_select_mask.update(self.extra_select_mask)
    if (rhs.extra_select_mask is not None):
        extra_select_mask.update(rhs.extra_select_mask)
    if extra_select_mask:
        self.set_extra_mask(extra_select_mask)
    self.extra_tables += rhs.extra_tables
    self.order_by = (rhs.order_by[:] if rhs.order_by else self.order_by)
    self.extra_order_by = (rhs.extra_order_by or self.extra_order_by)
