]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Tighten rules for order_by(Label) resolution
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 6 Jan 2017 22:02:32 +0000 (17:02 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 6 Jan 2017 22:56:41 +0000 (17:56 -0500)
commit6b489db89970b1fcec38a7c3772960ed3291a2ed
tree8caab4e8618f1864ab5029fbdab352aad9fbab80
parent2b4d028a69270c1c7918281a60280dd0b65963a2
Tighten rules for order_by(Label) resolution

- Fixed bug originally introduced in 0.9 via :ticket:`1068` where
order_by(<some Label()>) would order by the label name based on name
alone, that is, even if the labeled expression were not at all the same
expression otherwise present, implicitly or explicitly, in the
selectable.  The logic that orders by label now ensures that the
labeled expression is related to the one that resolves to that name
before ordering by the label name; additionally, the name has to
resolve to an actual label explicit in the expression elsewhere, not
just a column name.  This logic is carefully kept separate from the
order by(textual name) feature that has a slightly different purpose.

Change-Id: I44fc36dab34380cc238c1e79ecbe23f1628d588a
Fixes: #3882
doc/build/changelog/changelog_11.rst
lib/sqlalchemy/sql/compiler.py
lib/sqlalchemy/sql/selectable.py
test/sql/test_compiler.py