]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Adjust derivation rules for table vs. subquery against a join
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 16 Mar 2021 23:46:40 +0000 (19:46 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 23 Mar 2021 15:02:18 +0000 (11:02 -0400)
commit242867ec87c4d739011ee3cea9a53f33d9f05f2b
tree3e4aacfb77db1be73ee6492279bca54274b62473
parentda0c2def18ac21d191da122bd211ee0f48f646ae
Adjust derivation rules for table vs. subquery against a join

Fixed bug where ORM queries using a correlated subquery in conjunction with
:func:`_orm.column_property` would fail to correlate correctly to an
enclosing subquery or to a CTE when :meth:`_sql.Select.correlate_except`
were used in the property to control correlation, in cases where the
subquery contained the same selectables as ones within the correlated
subquery that were intended to not be correlated.

This is achieved by adding a limiting factor to ClauseAdapter
which is to explicitly pass the selectables we will be adapting
"from", which is then used by AliasedClass to limit "from"
to the mappers represented by the AliasedClass.

This did cause one test where an alias for a contains_eager()
was missing to suddenly fail, and the test was corrected, however
there may be some very edge cases like that one where the tighter
criteria causes an existing use case that's relying on the more
liberal aliasing to require modifications.

Fixes: #6060
Change-Id: I8342042641886e1a220beafeb94fe45ea7aadb33
doc/build/changelog/unreleased_14/6060.rst [new file with mode: 0644]
lib/sqlalchemy/orm/util.py
lib/sqlalchemy/sql/util.py
test/aaa_profiling/test_memusage.py
test/orm/test_froms.py
test/sql/test_external_traversal.py