Skip to content

Commit 403de6f

Browse files
Simon Heisterkampandialbrecht
authored andcommitted
Fixed bad parsing of create table statements that use lower case
1 parent a172486 commit 403de6f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

sqlparse/engine/grouping.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,9 @@ def group_functions(tlist):
343343
has_table = False
344344
has_as = False
345345
for tmp_token in tlist.tokens:
346-
if tmp_token.value == 'CREATE':
346+
if tmp_token.value.upper() == 'CREATE':
347347
has_create = True
348-
if tmp_token.value == 'TABLE':
348+
if tmp_token.value.upper() == 'TABLE':
349349
has_table = True
350350
if tmp_token.value == 'AS':
351351
has_as = True

tests/test_grouping.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,3 +660,7 @@ def test_grouping_as_cte():
660660
assert p[0].get_alias() is None
661661
assert p[2].value == 'AS'
662662
assert p[4].value == 'WITH'
663+
664+
def test_grouping_create_table():
665+
p = sqlparse.parse("create table db.tbl (a string)")[0].tokens
666+
assert p[4].value == "db.tbl"

0 commit comments

Comments
 (0)