summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-05-10 12:49:56 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2016-05-10 12:55:23 -0400
commit0604116814a862d4d9dbc1a8866a2a3b0126caf1 (patch)
tree1ddc470c634b5fb4cf474767b0d728817df5a142 /lib/sqlalchemy/sql
parent743e9d4589946f1a29cdec7f2f1a2e4ec0853db7 (diff)
downloadsqlalchemy-0604116814a862d4d9dbc1a8866a2a3b0126caf1.tar.gz
Fix label referencing in SQL Server OFFSET logic
Fixed bug where by ROW_NUMBER OVER clause applied for OFFSET selects in SQL Server would inappropriately substitute a plain column from the local statement that overlaps with a label name used by the ORDER BY criteria of the statement. Change-Id: Ic2500c886cbfc83a1ad5a2681783f008b9f23838 Fixes: #3711
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r--lib/sqlalchemy/sql/util.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/util.py b/lib/sqlalchemy/sql/util.py
index 5f180646c..24c6f5441 100644
--- a/lib/sqlalchemy/sql/util.py
+++ b/lib/sqlalchemy/sql/util.py
@@ -176,6 +176,16 @@ def unwrap_order_by(clause):
return result
+def unwrap_label_reference(element):
+ def replace(elem):
+ if isinstance(elem, (_label_reference, _textual_label_reference)):
+ return elem.element
+
+ return visitors.replacement_traverse(
+ element, {}, replace
+ )
+
+
def expand_column_list_from_order_by(collist, order_by):
"""Given the columns clause and ORDER BY of a selectable,
return a list of column expressions that can be added to the collist