From cc8e4f1b0321d65d244825b1006de68f8952e071 Mon Sep 17 00:00:00 2001 From: Tenghuan Date: Sun, 29 May 2016 11:30:21 +0800 Subject: CREATE TABLE should not be parsed as Function --- sqlparse/engine/grouping.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'sqlparse/engine') diff --git a/sqlparse/engine/grouping.py b/sqlparse/engine/grouping.py index e30abab..f7953e7 100644 --- a/sqlparse/engine/grouping.py +++ b/sqlparse/engine/grouping.py @@ -220,6 +220,15 @@ def group_typecasts(tlist): @recurse(sql.Function) def group_functions(tlist): + has_create = False + has_table = False + for tmp_token in tlist.tokens: + if tmp_token.value == u'CREATE': + has_create = True + if tmp_token.value == u'TABLE': + has_table = True + if has_create and has_table: + return token = tlist.token_next_by(t=T.Name) while token: next_ = tlist.token_next(token) -- cgit v1.2.1