]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
improve targeting and labeling for unary() in columns clause
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 6 Mar 2021 02:52:03 +0000 (21:52 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 6 Mar 2021 16:15:38 +0000 (11:15 -0500)
commitf62e0c0c7fc4be842a0f4dc4f59019b3c6285fee
tree73c3523c6d4191cfedc1c20130847f9751b43ebd
parent1f3ef9817453faa021544841d10b5b7107b57916
improve targeting and labeling for unary() in columns clause

Fixed regression where usage of the standalone :func:`_sql.distinct()` used
in the form of being directly SELECTed would fail to be locatable in the
result set by column identity, which is how the ORM locates columns. While
standalone :func:`_sql.distinct()` is not oriented towards being directly
SELECTed (use :meth:`_sql.select.distinct` for a regular
``SELECT DISTINCT..``) , it was usable to a limited extent in this way
previously (but wouldn't work in subqueries, for example). The column
targeting for unary expressions such as "DISTINCT <col>" has been improved
so that this case works again, and an additional improvement has been made
so that usage of this form in a subquery at least generates valid SQL which
was not the case previously.

The change additionally enhances the ability to target elements in
``row._mapping`` based on SQL expression objects in ORM-enabled
SELECT statements, including whether the statement was invoked by
``connection.execute()`` or ``session.execute()``.

Fixes: #6008
Change-Id: I5cfa39435f5418861d70a7db8f52ab4ced6a792e
doc/build/changelog/unreleased_14/6008.rst [new file with mode: 0644]
lib/sqlalchemy/engine/cursor.py
lib/sqlalchemy/orm/context.py
lib/sqlalchemy/sql/compiler.py
test/orm/test_cache_key.py
test/orm/test_eager_relations.py
test/orm/test_query.py
test/sql/test_compiler.py