summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/compiler.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-09-07 00:01:34 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-09-07 00:01:34 -0400
commit7950270cf2b12807acd7c330b11dae36e50c3a28 (patch)
treef1ec50aa6fc604d7a2dadf1b41aff73952a05dcc /lib/sqlalchemy/sql/compiler.py
parente80c7cc5c103788a4c7e1c479af2c37cd9c958b3 (diff)
downloadsqlalchemy-7950270cf2b12807acd7c330b11dae36e50c3a28.tar.gz
- enhance ClauseAdapter / ColumnAdapter to have new behaviors with labels.
The "anonymize label" logic is now generalized to ClauseAdapter, and takes place when the anonymize_labels flag is sent, taking effect for all .columns lookups as well as within traverse() calls against the label directly. - traverse() will also memoize what it gets in columns, so that calling upon traverse() / .columns against the same Label will produce the same anonymized label. This is so that AliasedClass produces the same anonymized label when it is accessed per-column (e.g. SomeAlias.some_column) as well as when it is applied to a Query, and within column loader strategies (e.g. query(SomeAlias)); the former uses traverse() while the latter uses .columns - AliasedClass now calls onto ColumnAdapter - Query also makes sure to use that same ColumnAdapter from the AliasedClass in all cases - update the logic from 0.9 in #1068 to make use of the same _label_resolve_dict we use for #2992, simplifying how that works and adding support for new scenarios that were pretty broken (see #3148, #3188)
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r--lib/sqlalchemy/sql/compiler.py10
1 files changed, 2 insertions, 8 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index 4349c97f4..72dd11eaf 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -701,13 +701,7 @@ class SQLCompiler(Compiled):
# here; we can only add a label in the ORDER BY for an individual
# label expression in the columns clause.
- # TODO: we should see if we can bring _resolve_label
- # into this
-
-
- raw_col = set(l._order_by_label_element.name
- for l in order_by_select._raw_columns
- if l._order_by_label_element is not None)
+ raw_col = set(order_by_select._label_resolve_dict.keys())
return ", ".join(
s for s in
@@ -716,7 +710,7 @@ class SQLCompiler(Compiled):
self,
render_label_as_label=c._order_by_label_element if
c._order_by_label_element is not None and
- c._order_by_label_element.name in raw_col
+ c._order_by_label_element._label in raw_col
else None,
**kw)
for c in clauselist.clauses)