summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-01-20 17:06:14 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2021-01-20 17:07:22 -0500
commitb6ff056b91834ec56f685c8735cd67c9b0603de7 (patch)
treeb7f313f12c3cf756fa735d1547cddb712ddf585a /lib/sqlalchemy/sql
parent3df145c57c966e1511bccc117161563123ec6f0b (diff)
downloadsqlalchemy-b6ff056b91834ec56f685c8735cd67c9b0603de7.tar.gz
chain joins from SelectState context, not Select
Fixed issue in new :meth:`_sql.Select.join` method where chaining from the current JOIN wasn't looking at the right state, causing an expression like "FROM a JOIN b <onclause>, b JOIN c <onclause>" rather than "FROM a JOIN b <onclause> JOIN c <onclause>". Added :meth:`_sql.Select.outerjoin_from` method to complement :meth:`_sql.Select.join_from`. Fixes: #5858 Change-Id: I1346ebe0963bbd1e4bf868650e3ee1d6d3072f04
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r--lib/sqlalchemy/sql/selectable.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py
index b4f6c8bc9..8e478583f 100644
--- a/lib/sqlalchemy/sql/selectable.py
+++ b/lib/sqlalchemy/sql/selectable.py
@@ -3944,7 +3944,7 @@ class SelectState(util.MemoizedSlots, CompileState):
replace_from_obj_index = None
- from_clauses = self.statement._from_obj
+ from_clauses = self.from_clauses
if from_clauses:
@@ -4644,6 +4644,19 @@ class Select(
(target, onclause, None, {"isouter": isouter, "full": full}),
)
+ def outerjoin_from(self, from_, target, onclause=None, full=False):
+ r"""Create a SQL LEFT OUTER JOIN against this :class:`_expression.Select`
+ object's criterion
+ and apply generatively, returning the newly resulting
+ :class:`_expression.Select`.
+
+ Usage is the same as that of :meth:`_selectable.Select.join_from`.
+
+ """
+ return self.join_from(
+ from_, target, onclause=onclause, isouter=True, full=full
+ )
+
@_generative
def join_from(
self, from_, target, onclause=None, isouter=False, full=False