]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
fixes for usage of the null() and similar constants
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 6 Oct 2021 22:51:08 +0000 (18:51 -0400)
committermike bayer <mike_mp@zzzcomputing.com>
Fri, 8 Oct 2021 17:09:33 +0000 (17:09 +0000)
commitb7226379ac06c9a1a78e783deaa60c701b1b7e88
treeea76576d3d9c58684e7bbcc65627a5f99021d636
parent64e6da307c79981119cbd6f95957ead310e3456f
fixes for usage of the null() and similar constants

Adjusted the "column disambiguation" logic that's new in 1.4, where the
same expression repeated gets an "extra anonymous" label, so that the logic
more aggressively deduplicates those labels when the repeated element
is the same Python expression object each time, as occurs in cases like
when using "singleton" values like :func:`_sql.null`.  This is based on
the observation that at least some databases (e.g. MySQL, but not SQLite)
will raise an error if the same label is repeated inside of a subquery.

Related to :ticket:`7153`, fixed an issue where result column lookups
would fail for "adapted" SELECT statements that selected for
"constant" value expressions most typically the NULL expression,
as would occur in such places as joined eager loading in conjunction
with limit/offset.  This was overall a regression due to issue
:ticket:`6259` which removed all "adaption" for constants like NULL,
"true", and "false", but this broke the case where the same adaption
logic were used to match the constant to a labeled expression referring
to the constant in a subquery.

Fixes: #7153
Fixes: #7154
Change-Id: I43823343721b9e70524ea3f5e8f39dd543a3e92b
lib/sqlalchemy/sql/base.py
lib/sqlalchemy/sql/elements.py
lib/sqlalchemy/sql/selectable.py
lib/sqlalchemy/sql/util.py
test/orm/test_core_compilation.py
test/orm/test_eager_relations.py
test/orm/test_query.py
test/sql/test_compiler.py
test/sql/test_cte.py
test/sql/test_resultset.py
test/sql/test_selectable.py