diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-05-17 11:20:10 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-05-17 12:26:48 -0400 |
commit | a49b2c3dbb9bff1d004eb2c53a752999e27ff769 (patch) | |
tree | 3190734880c30a52c3fbc7ec92ab4dbd164fe17b /lib/sqlalchemy/orm/context.py | |
parent | c379f80b4e6fb1b65983958116bac202c91a210a (diff) | |
download | sqlalchemy-a49b2c3dbb9bff1d004eb2c53a752999e27ff769.tar.gz |
Run SelectState from obj normalize ahead of calcing ORM joins
Fixed regression where the full combination of joined inheritance, global
with_polymorphic, self-referential relationship and joined loading would
fail to be able to produce a query with the scope of lazy loads and object
refresh operations that also attempted to render the joined loader.
Fixes: #6495
Change-Id: If74a744c237069e3a89617498096c18b9b6e5dde
Diffstat (limited to 'lib/sqlalchemy/orm/context.py')
-rw-r--r-- | lib/sqlalchemy/orm/context.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/context.py b/lib/sqlalchemy/orm/context.py index ea84805b4..baad28835 100644 --- a/lib/sqlalchemy/orm/context.py +++ b/lib/sqlalchemy/orm/context.py @@ -591,9 +591,15 @@ class ORMSelectCompileState(ORMCompileState, SelectState): self.create_eager_joins = [] self._fallback_from_clauses = [] - self.from_clauses = [ + # normalize the FROM clauses early by themselves, as this makes + # it an easier job when we need to assemble a JOIN onto these, + # for select.join() as well as joinedload(). As of 1.4 there are now + # potentially more complex sets of FROM objects here as the use + # of lambda statements for lazyload, load_on_pk etc. uses more + # cloning of the select() construct. See #6495 + self.from_clauses = self._normalize_froms( info.selectable for info in select_statement._from_obj - ] + ) # this is a fairly arbitrary break into a second method, # so it might be nicer to break up create_for_statement() |