]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
create second level deduping when use_labels is turned on
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 5 Oct 2019 22:27:44 +0000 (18:27 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 7 Oct 2019 15:26:10 +0000 (11:26 -0400)
commite0396633e72bc09bd7cec715101d516ea87fa840
tree9486b4566942af674e669eddc38c14bee1e2ecfd
parentc6abd4766abb0396c9bf532d81d16226b970a35a
create second level deduping when use_labels is turned on

As of #4753 we allow duplicate columns.  This creates some new
problems that there can be duplicate columns in a subquery
which are then not addressible on the outside because they
are ambiguous (Postgresql has this behavior at least).  Additionally
it creates situations where we are making an anon label of an
anon label which is leaking into the query.

New logic for generating anon labels handles this situation and
also alters the .c collection
of a subquery such that we are only getting the first column
from the derived selectable that has that name, the subsequent ones
have a new deduping label with two underscores and are not exposed
in .c.  The dedupe logic when rendering the columns will handle
duplicate label names for different columns, vs. the same column
repeated, as separate cases.

Fixes: #4892
Change-Id: I929fbd8da14bcc239e0481c24bbd9b5ce826e8fa
lib/sqlalchemy/sql/elements.py
lib/sqlalchemy/sql/selectable.py
test/sql/test_compiler.py
test/sql/test_join_rewriting.py
test/sql/test_labels.py
test/sql/test_selectable.py