summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-10-27 11:14:50 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2021-10-27 11:14:50 -0400
commit5ad4190aa428dabc571e3d9c0e6a7944a384c8c3 (patch)
tree226695dc956ec6ce116792c84347e52486ad109a /lib/sqlalchemy/orm
parentd2cf7dcfe0cd7e9986376b6e7edd4b7d60108599 (diff)
downloadsqlalchemy-5ad4190aa428dabc571e3d9c0e6a7944a384c8c3.tar.gz
consider "inspect(_of_type)" to be the entity of a comparator
Fixed 1.4 regression where :meth:`_orm.Query.filter_by` would not function correctly when :meth:`_orm.Query.join` were joined to an entity which made use of :meth:`_orm.PropComparator.of_type` to specify an aliased version of the target entity. The issue also applies to future style ORM queries constructed with :func:`_sql.select`. Fixes: #7244 Change-Id: Ied28a03ce93201f932c7172d283cd4297be4d592
Diffstat (limited to 'lib/sqlalchemy/orm')
-rw-r--r--lib/sqlalchemy/orm/interfaces.py5
-rw-r--r--lib/sqlalchemy/orm/relationships.py8
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/interfaces.py b/lib/sqlalchemy/orm/interfaces.py
index 903672c80..9eb362c43 100644
--- a/lib/sqlalchemy/orm/interfaces.py
+++ b/lib/sqlalchemy/orm/interfaces.py
@@ -475,7 +475,8 @@ class PropComparator(operators.ColumnOperators):
def of_type(self, class_):
r"""Redefine this object in terms of a polymorphic subclass,
- :func:`.with_polymorphic` construct, or :func:`.aliased` construct.
+ :func:`_orm.with_polymorphic` construct, or :func:`_orm.aliased`
+ construct.
Returns a new PropComparator from which further criterion can be
evaluated.
@@ -490,6 +491,8 @@ class PropComparator(operators.ColumnOperators):
.. seealso::
+ :ref:`queryguide_join_onclause` - in the :ref:`queryguide_toplevel`
+
:ref:`inheritance_of_type`
"""
diff --git a/lib/sqlalchemy/orm/relationships.py b/lib/sqlalchemy/orm/relationships.py
index 3916c0a83..d021ac9a2 100644
--- a/lib/sqlalchemy/orm/relationships.py
+++ b/lib/sqlalchemy/orm/relationships.py
@@ -1161,7 +1161,13 @@ class RelationshipProperty(StrategizedProperty):
:func:`_orm.relationship`.
"""
- return self.property.entity
+ # this is a relatively recent change made for
+ # 1.4.27 as part of #7244.
+ # TODO: shouldn't _of_type be inspected up front when received?
+ if self._of_type is not None:
+ return inspect(self._of_type)
+ else:
+ return self.property.entity
@util.memoized_property
def mapper(self):