summaryrefslogtreecommitdiff
path: root/sqlparse/engine
diff options
context:
space:
mode:
authorAndi Albrecht <albrecht.andi@gmail.com>2011-09-29 11:19:26 +0200
committerAndi Albrecht <albrecht.andi@gmail.com>2011-09-29 11:19:26 +0200
commit13c1d716a7798ae1a79c524dc967e9a33c534ff4 (patch)
tree5486734ad09578e3eb538a3faf545ae0681d0190 /sqlparse/engine
parentff50b33074f5c276b0cff8094e85582dcd467095 (diff)
downloadsqlparse-13c1d716a7798ae1a79c524dc967e9a33c534ff4.tar.gz
Detect alias for CASE statements (targets issue46).
Diffstat (limited to 'sqlparse/engine')
-rw-r--r--sqlparse/engine/grouping.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/sqlparse/engine/grouping.py b/sqlparse/engine/grouping.py
index cc75de4..f92a812 100644
--- a/sqlparse/engine/grouping.py
+++ b/sqlparse/engine/grouping.py
@@ -274,21 +274,20 @@ def group_where(tlist):
def group_aliased(tlist):
+ clss = (sql.Identifier, sql.Function, sql.Case)
[group_aliased(sgroup) for sgroup in tlist.get_sublists()
- if not isinstance(sgroup, (sql.Identifier, sql.Function))]
+ if not isinstance(sgroup, clss)]
idx = 0
- token = tlist.token_next_by_instance(idx, (sql.Identifier, sql.Function))
+ token = tlist.token_next_by_instance(idx, clss)
while token:
next_ = tlist.token_next(tlist.token_index(token))
- if next_ is not None and isinstance(next_,
- (sql.Identifier, sql.Function)):
+ if next_ is not None and isinstance(next_, clss):
grp = tlist.tokens_between(token, next_)[1:]
token.tokens.extend(grp)
for t in grp:
tlist.tokens.remove(t)
idx = tlist.token_index(token) + 1
- token = tlist.token_next_by_instance(idx,
- (sql.Identifier, sql.Function))
+ token = tlist.token_next_by_instance(idx, clss)
def group_typecasts(tlist):