diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-04-05 17:37:56 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-04-05 19:26:12 -0400 |
| commit | 03122c8d060ddc8d8194017dc2cd7e4a1c09c1e1 (patch) | |
| tree | ca64e8a71d37669ee04aaa11dae8fd493e4544e2 /lib/sqlalchemy | |
| parent | 165c3a65dcb1ba3f42ecf2b5da7c298bdc259f9b (diff) | |
| download | sqlalchemy-03122c8d060ddc8d8194017dc2cd7e4a1c09c1e1.tar.gz | |
Detect (Entity, Entity) vs (Entity, onclause) in legacy join
Fixed regression where a deprecated form of :meth:`_orm.Query.join` were
used, passing a series of entities to join from without any ON clause in a
single :meth:`_orm.Query.join` call, would fail to function correctly.
Fixes: #6203
Change-Id: I5a6ec80de972af5b2ca9054e6f24a0b8af4a3e13
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/orm/query.py | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index 7e2fde749..90ae1b700 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -22,7 +22,6 @@ import itertools import operator import types -from sqlalchemy.sql import visitors from . import exc as orm_exc from . import interfaces from . import loading @@ -48,10 +47,12 @@ from .. import log from .. import sql from .. import util from ..sql import coercions +from ..sql import elements from ..sql import expression from ..sql import roles from ..sql import Select from ..sql import util as sql_util +from ..sql import visitors from ..sql.annotation import SupportsCloneAnnotations from ..sql.base import _entity_namespace_key from ..sql.base import _generative @@ -2167,6 +2168,8 @@ class Query( (Item, Item.order_id == Order.id) ) + session.query(User).join(Order, Item) + # ... and several more forms actually **Why it's legacy**: being able to chain multiple ON clauses in one @@ -2259,9 +2262,26 @@ class Query( if not legacy and onclause is None and not isinstance(target, tuple): # non legacy argument form _props = [(target,)] - elif not legacy and isinstance( - target, - (expression.Selectable, type, AliasedClass, types.FunctionType), + elif ( + not legacy + and isinstance( + target, + ( + expression.Selectable, + type, + AliasedClass, + types.FunctionType, + ), + ) + and isinstance( + onclause, + ( + elements.ColumnElement, + str, + interfaces.PropComparator, + types.FunctionType, + ), + ) ): # non legacy argument form _props = [(target, onclause)] |
