def _join_to_left(self, l_info, left, right, onclause, outerjoin):
    info = l_info
    left_mapper = getattr(info, 'mapper', None)
    left_selectable = info.selectable
    if self._from_obj:
        (replace_clause_index, clause) = sql_util.find_join_source(self._from_obj, left_selectable)
        if (clause is not None):
            try:
                clause = orm_join(clause, right, onclause, isouter=outerjoin)
            except sa_exc.ArgumentError as ae:
                raise sa_exc.InvalidRequestError(('Could not find a FROM clause to join from.  Tried joining to %s, but got: %s' % (right, ae)))
            self._from_obj = ((self._from_obj[:replace_clause_index] + (clause,)) + self._from_obj[(replace_clause_index + 1):])
            return
    if left_mapper:
        for ent in self._entities:
            if ent.corresponds_to(left):
                clause = ent.selectable
                break
        else:
            clause = left
    else:
        clause = left_selectable
    assert (clause is not None)
    try:
        clause = orm_join(clause, right, onclause, isouter=outerjoin)
    except sa_exc.ArgumentError as ae:
        raise sa_exc.InvalidRequestError(('Could not find a FROM clause to join from.  Tried joining to %s, but got: %s' % (right, ae)))
    self._from_obj = (self._from_obj + (clause,))
def _join_to_left(self, l_info, left, right, onclause, outerjoin):
    info = l_info
    left_mapper = getattr(info, 'mapper', None)
    left_selectable = info.selectable
    if self._from_obj:
        (replace_clause_index, clause) = sql_util.find_join_source(self._from_obj, left_selectable)
        if (clause is not None):
            try:
                clause = orm_join(clause, right, onclause, isouter=outerjoin)
            except sa_exc.ArgumentError as ae:
                raise sa_exc.InvalidRequestError(('Could not find a FROM clause to join from.  Tried joining to %s, but got: %s' % (right, ae)))
            self._from_obj = ((self._from_obj[:replace_clause_index] + (clause,)) + self._from_obj[(replace_clause_index + 1):])
            return
    if left_mapper:
        for ent in self._entities:
            if ent.corresponds_to(left):
                clause = ent.selectable
                break
        else:
            clause = left
    else:
        clause = left_selectable
    assert (clause is not None)
    try:
        clause = orm_join(clause, right, onclause, isouter=outerjoin)
    except sa_exc.ArgumentError as ae:
        raise sa_exc.InvalidRequestError(('Could not find a FROM clause to join from.  Tried joining to %s, but got: %s' % (right, ae)))
    self._from_obj = (self._from_obj + (clause,))