From f8914288f012c4ef635531f09a0e13bcacacdb2a Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 25 Feb 2016 23:22:30 -0500 Subject: - An improvement to the workings of :meth:`.Query.correlate` such that when a "polymorphic" entity is used which represents a straight join of several tables, the statement will ensure that all the tables within the join are part of what's correlating. fixes #3662 --- lib/sqlalchemy/orm/query.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'lib/sqlalchemy') diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index ad7b9130b..f68a30917 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -882,12 +882,15 @@ class Query(object): a subquery as returned by :meth:`.Query.subquery` is embedded in another :func:`~.expression.select` construct. - """ + """ - self._correlate = self._correlate.union( - _interpret_as_from(s) - if s is not None else None - for s in args) + for s in args: + if s is None: + self._correlate = self._correlate.union([None]) + else: + self._correlate = self._correlate.union( + sql_util.surface_selectables(_interpret_as_from(s)) + ) @_generative() def autoflush(self, setting): -- cgit v1.2.1