summaryrefslogtreecommitdiff
path: root/sqlparse
diff options
context:
space:
mode:
authorAndi Albrecht <albrecht.andi@gmail.com>2011-07-24 00:07:38 +0200
committerAndi Albrecht <albrecht.andi@gmail.com>2011-07-24 00:07:38 +0200
commit6c5a777bb6e144aeb0d41490148734ecd5ecb895 (patch)
treeeecfd309d174069d1234288b500cd40dc445acb4 /sqlparse
parentbb6453b96a4d7ecfc47322398768b5857e5e73f2 (diff)
downloadsqlparse-6c5a777bb6e144aeb0d41490148734ecd5ecb895.tar.gz
Detect function aliases better.
Diffstat (limited to 'sqlparse')
-rw-r--r--sqlparse/engine/grouping.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/sqlparse/engine/grouping.py b/sqlparse/engine/grouping.py
index c682419..9bc9612 100644
--- a/sqlparse/engine/grouping.py
+++ b/sqlparse/engine/grouping.py
@@ -175,6 +175,7 @@ def group_identifier_list(tlist):
# Allowed list items
fend1_funcs = [lambda t: isinstance(t, (sql.Identifier, sql.Function)),
lambda t: t.is_whitespace(),
+ lambda t: t.ttype == T.Name,
lambda t: t.ttype == T.Wildcard,
lambda t: t.match(T.Keyword, 'null'),
lambda t: t.ttype == T.Number.Integer,
@@ -261,18 +262,18 @@ def group_where(tlist):
def group_aliased(tlist):
[group_aliased(sgroup) for sgroup in tlist.get_sublists()
- if not isinstance(sgroup, sql.Identifier)]
+ if not isinstance(sgroup, (sql.Identifier, sql.Function))]
idx = 0
- token = tlist.token_next_by_instance(idx, sql.Identifier)
+ token = tlist.token_next_by_instance(idx, (sql.Identifier, sql.Function))
while token:
next_ = tlist.token_next(tlist.token_index(token))
- if next_ is not None and isinstance(next_, sql.Identifier):
+ if next_ is not None and isinstance(next_, (sql.Identifier, sql.Function)):
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)
+ token = tlist.token_next_by_instance(idx, (sql.Identifier, sql.Function))
def group_typecasts(tlist):