]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Don't stringify unnamed column elements when proxying
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 16 Apr 2021 15:06:56 +0000 (11:06 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 17 Apr 2021 04:40:52 +0000 (00:40 -0400)
commit9f758d7fe328107cd3d047b8c999dce228a570d1
tree9867a6dbdf81d5111907e4a49c86d6e06488f0c9
parentb3d764fa768756cd7aef73253ccceac456c76c81
Don't stringify unnamed column elements when proxying

Repaired and solidified issues regarding custom functions and other
arbitrary expression constructs which within SQLAlchemy's column labeling
mechanics would seek to use ``str(obj)`` to get a string representation to
use as an anonymous column name in the ``.c`` collection of a subquery.
This is a very legacy behavior that performs poorly and leads to lots of
issues, so has been revised to no longer perform any compilation by
establishing specific methods on :class:`.FunctionElement` to handle this
case, as SQL functions are the only use case that it came into play. An
effect of this behavior is that an unlabeled column expression with no
derivable name will be given an arbitrary label starting with the prefix
``"_no_label"`` in the ``.c`` collection of a subquery; these were
previously being represented either as the generic stringification of that
expression, or as an internal symbol.

This change seeks to make the concept of "anon name" more private
and renames anon_label and anon_key_label to _anon_name_label
and _anon_key_label.   There's no end-user utility to these accessors
and we need to be able to reorganize these as well.

Fixes: #6256
Change-Id: Ie63c86b20ca45873affea78500388da94cf8bf94
doc/build/changelog/unreleased_14/6256.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/oracle/base.py
lib/sqlalchemy/dialects/oracle/cx_oracle.py
lib/sqlalchemy/sql/compiler.py
lib/sqlalchemy/sql/elements.py
lib/sqlalchemy/sql/selectable.py
test/ext/test_compiler.py
test/sql/test_compiler.py
test/sql/test_external_traversal.py
test/sql/test_selectable.py