From 403de6fc648ac4e012b60b49161c3f5f36dc944a Mon Sep 17 00:00:00 2001 From: Simon Heisterkamp Date: Sun, 19 Sep 2021 11:56:46 +0200 Subject: [PATCH] Fixed bad parsing of create table statements that use lower case --- sqlparse/engine/grouping.py | 4 ++-- tests/test_grouping.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/sqlparse/engine/grouping.py b/sqlparse/engine/grouping.py index d250e181..86d8fc64 100644 --- a/sqlparse/engine/grouping.py +++ b/sqlparse/engine/grouping.py @@ -343,9 +343,9 @@ def group_functions(tlist): has_table = False has_as = False for tmp_token in tlist.tokens: - if tmp_token.value == 'CREATE': + if tmp_token.value.upper() == 'CREATE': has_create = True - if tmp_token.value == 'TABLE': + if tmp_token.value.upper() == 'TABLE': has_table = True if tmp_token.value == 'AS': has_as = True diff --git a/tests/test_grouping.py b/tests/test_grouping.py index 8c034f9d..546ad4b2 100644 --- a/tests/test_grouping.py +++ b/tests/test_grouping.py @@ -660,3 +660,7 @@ def test_grouping_as_cte(): assert p[0].get_alias() is None assert p[2].value == 'AS' assert p[4].value == 'WITH' + +def test_grouping_create_table(): + p = sqlparse.parse("create table db.tbl (a string)")[0].tokens + assert p[4].value == "db.tbl"