From fb377229cd4c4e503bde9c44b78d30ad48f3cf7e Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 14 Jul 2018 12:26:29 -0400 Subject: Don't apply no-traverse to query.statement Fixed long-standing issue in :class:`.Query` where a scalar subquery such as produced by :meth:`.Query.exists`, :meth:`.Query.as_scalar` and other derivations from :attr:`.Query.statement` would not correctly be adapted when used in a new :class:`.Query` that required entity adaptation, such as when the query were turned into a union, or a from_self(), etc. The change removes the "no adaptation" annotation from the :func:`.select` object produced by the :attr:`.Query.statement` accessor. Change-Id: I554e0e909ac6ee785ec3b3b14aaec9d235aa28cf Fixes: #4304 --- lib/sqlalchemy/orm/query.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib/sqlalchemy') diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index 272fed3e2..627a4e01c 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -512,9 +512,7 @@ class Query(object): if self._params: stmt = stmt.params(self._params) - # TODO: there's no tests covering effects of - # the annotation not being there - return stmt._annotate({'no_replacement_traverse': True}) + return stmt def subquery(self, name=None, with_labels=False, reduce_columns=False): """return the full SELECT statement represented by -- cgit v1.2.1