summaryrefslogtreecommitdiff
path: root/sqlparse/engine/grouping.py
diff options
context:
space:
mode:
Diffstat (limited to 'sqlparse/engine/grouping.py')
-rw-r--r--sqlparse/engine/grouping.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/sqlparse/engine/grouping.py b/sqlparse/engine/grouping.py
index 175ae8e..2fb0a4c 100644
--- a/sqlparse/engine/grouping.py
+++ b/sqlparse/engine/grouping.py
@@ -91,13 +91,20 @@ def group_tzcasts(tlist):
def match(token):
return token.ttype == T.Keyword.TZCast
- def valid(token):
+ def valid_prev(token):
return token is not None
+ def valid_next(token):
+ return token is not None and (
+ token.is_whitespace
+ or token.match(T.Keyword, 'AS')
+ or token.match(*sql.TypedLiteral.M_CLOSE)
+ )
+
def post(tlist, pidx, tidx, nidx):
return pidx, nidx
- _group(tlist, sql.Identifier, match, valid, valid, post)
+ _group(tlist, sql.Identifier, match, valid_prev, valid_next, post)
def group_typed_literal(tlist):