From e6572789bb6fec5f1ac07653908c0f29d7904ece Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 31 May 2019 16:47:19 -0400 Subject: Apply adaptation for most recent aliased=True first Fixed regression in :meth:`.Query.join` where the ``aliased=True`` flag would not properly apply clause adaptation to filter criteria, if a previous join were made to the same entity. This is because the adapters were placed in the wrong order. The order has been reversed so that the adapter for the most recent ``aliased=True`` call takes precedence as was the case in 1.2 and earlier. This broke the "elementtree" examples among other things. Fixes: #4704 Change-Id: I69f76c97b11157100854d552b5a0ce0103642ec4 --- lib/sqlalchemy/orm/query.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy') diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index 01a96d7b5..8f05a47b8 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -1769,7 +1769,6 @@ class Query(object): """ for criterion in list(criterion): criterion = coercions.expect(roles.WhereHavingRole, criterion) - criterion = self._adapt_clause(criterion, True, True) if self._criterion is not None: @@ -2800,7 +2799,8 @@ class Query(object): adapter = ORMAdapter( right, equivalents=right_mapper._equivalent_columns ) - self._filter_aliases += (adapter,) + # current adapter takes highest precedence + self._filter_aliases = (adapter,) + self._filter_aliases # if an alias() on the right side was generated, # which is intended to wrap a the right side in a subquery, -- cgit v1.2.1