diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-12-08 14:19:11 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-12-08 19:32:44 -0500 |
commit | 9e20d410212296517f8dffd2531d55fee196635b (patch) | |
tree | c6c9123d70dc7c6580321517889933fb0159fff3 /lib/sqlalchemy/orm/context.py | |
parent | 356c5268e0e90cd6d212e75e7cd3206c2aa4c4a3 (diff) | |
download | sqlalchemy-9e20d410212296517f8dffd2531d55fee196635b.tar.gz |
Removals: strings for join(), loader_options().
* The :meth:`_orm.Query.join` method no longer accepts strings for
relationship names; the long-documented approach of using
``Class.attrname`` for join targets is now standard.
* Loader options no longer accept strings for attribute names. The
long-documented approach of using ``Class.attrname`` for loader option
targets is now standard.
It is hoped that a subsequent commit can refactor loader
options to no longer need "UnboundLoad" for most cases.
Change-Id: If4629882c40523dccbf4459256bf540fb468b618
References: #6986
Diffstat (limited to 'lib/sqlalchemy/orm/context.py')
-rw-r--r-- | lib/sqlalchemy/orm/context.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/sqlalchemy/orm/context.py b/lib/sqlalchemy/orm/context.py index 4a3d5286b..8e3dc3134 100644 --- a/lib/sqlalchemy/orm/context.py +++ b/lib/sqlalchemy/orm/context.py @@ -1457,7 +1457,7 @@ class ORMSelectCompileState(ORMCompileState, SelectState): # legacy ^^^^^^^^^^^^^^^^^^^^^^^^^^^ if ( - isinstance(right, (interfaces.PropComparator, str)) + isinstance(right, interfaces.PropComparator) and onclause is None ): onclause = right @@ -1478,11 +1478,9 @@ class ORMSelectCompileState(ORMCompileState, SelectState): of_type = None if isinstance(onclause, str): - # string given, e.g. query(Foo).join("bar"). - # we look to the left entity or what we last joined - # towards - onclause = _entity_namespace_key( - inspect(self._joinpoint_zero()), onclause + raise sa_exc.ArgumentError( + "ORM mapped attributes as join targets must be " + "stated the attribute itself, not string name" ) # legacy vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv @@ -1495,7 +1493,7 @@ class ORMSelectCompileState(ORMCompileState, SelectState): # to work with the aliased=True flag, which is also something # that probably shouldn't exist on join() due to its high # complexity/usefulness ratio - elif from_joinpoint and isinstance( + if from_joinpoint and isinstance( onclause, interfaces.PropComparator ): jp0 = self._joinpoint_zero() |