diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-03-29 09:48:24 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-03-29 10:07:30 -0400 |
| commit | a55476fbdbc9b4e192a052b81dfe7e750d6241e4 (patch) | |
| tree | 7dc6802b398cfeb8e31e3d0dd1d10ba4dd40edfb /lib/sqlalchemy | |
| parent | 4fd4e4b0d6d20586614a18c3365476184d1a6a70 (diff) | |
| download | sqlalchemy-a55476fbdbc9b4e192a052b81dfe7e750d6241e4.tar.gz | |
use annotated entity when adding secondary
Fixed regression in "dynamic" loader strategy where the
:meth:`_orm.Query.filter_by` method would not be given an appropriate
entity to filter from, in the case where a "secondary" table were present
in the relationship being queried and the mapping were against something
complex such as a "with polymorphic".
Fixes: #7868
Change-Id: I3b82eec6485c5a92b56a596da0cfb009e9e67883
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/orm/dynamic.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/dynamic.py b/lib/sqlalchemy/orm/dynamic.py index 52a6ec4b0..a3b02bb94 100644 --- a/lib/sqlalchemy/orm/dynamic.py +++ b/lib/sqlalchemy/orm/dynamic.py @@ -304,7 +304,10 @@ class AppenderMixin: # is in the FROM. So we purposely put the mapper selectable # in _from_obj[0] to ensure a user-defined join() later on # doesn't fail, and secondary is then in _from_obj[1]. - self._from_obj = (prop.mapper.selectable, prop.secondary) + + # note also, we are using the official ORM-annotated selectable + # from __clause_element__(), see #7868 + self._from_obj = (prop.mapper.__clause_element__(), prop.secondary) self._where_criteria = ( prop._with_parent(instance, alias_secondary=False), |
