diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2020-08-13 21:43:09 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2020-08-13 21:43:09 +0000 |
| commit | b1c3c40e54bafe686065827d5b8d92c35bc50648 (patch) | |
| tree | 8a38d06678f6e89aed04a9e9e285f0c4bd0815f6 /lib/sqlalchemy/sql | |
| parent | cd03b8f0cecbf72ecd6c99c4d3a6338c8278b40d (diff) | |
| parent | 9c0b7baa956a7309f0a95fc36322a759b293eba1 (diff) | |
| download | sqlalchemy-b1c3c40e54bafe686065827d5b8d92c35bc50648.tar.gz | |
Merge "Further fixes for ticket 5470"
Diffstat (limited to 'lib/sqlalchemy/sql')
| -rw-r--r-- | lib/sqlalchemy/sql/util.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/sqlalchemy/sql/util.py b/lib/sqlalchemy/sql/util.py index 814253266..b3ead718a 100644 --- a/lib/sqlalchemy/sql/util.py +++ b/lib/sqlalchemy/sql/util.py @@ -27,6 +27,7 @@ from .elements import _textual_label_reference from .elements import BindParameter from .elements import ColumnClause from .elements import ColumnElement +from .elements import Grouping from .elements import Label from .elements import Null from .elements import UnaryExpression @@ -298,6 +299,9 @@ def unwrap_order_by(clause): ): t = t.element + if isinstance(t, Grouping): + t = t.element + stack.append(t) continue elif isinstance(t, _label_reference): @@ -310,6 +314,7 @@ def unwrap_order_by(clause): if t not in cols: cols.add(t) result.append(t) + else: for c in t.get_children(): stack.append(c) @@ -338,11 +343,9 @@ def expand_column_list_from_order_by(collist, order_by): ] ) - return [ - col - for col in chain(*[unwrap_order_by(o) for o in order_by]) - if col not in cols_already_present - ] + to_look_for = list(chain(*[unwrap_order_by(o) for o in order_by])) + + return [col for col in to_look_for if col not in cols_already_present] def clause_is_present(clause, search): |
