diff --git a/AUTHORS b/AUTHORS index 872c7007..0a8e884f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -82,6 +82,7 @@ Alphabetical list of contributors: * Victor Hahn * Victor Uriarte * Ville Skyttä +* Vincent Gao * vthriller * wayne.wuw * Will Jones diff --git a/CHANGELOG b/CHANGELOG index edfedb4f..ec187aaa 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -33,6 +33,8 @@ Bug Fixes * Fix statement splitting (issue845). * Fix a late-binding closure bug in `TokenList.token_not_matching`. +* Recognize ``MATERIALIZED`` as a keyword so it is parsed and formatted + consistently in ``CREATE MATERIALIZED VIEW`` statements (issue752). Release 0.5.5 (Dec 19, 2025) diff --git a/sqlparse/keywords.py b/sqlparse/keywords.py index 4bafcda1..631aa2e0 100644 --- a/sqlparse/keywords.py +++ b/sqlparse/keywords.py @@ -359,6 +359,7 @@ # 'M': tokens.Keyword, 'MAP': tokens.Keyword, 'MATCH': tokens.Keyword, + 'MATERIALIZED': tokens.Keyword, 'MAXEXTENTS': tokens.Keyword, 'MAXVALUE': tokens.Keyword, 'MESSAGE_LENGTH': tokens.Keyword, diff --git a/tests/test_regressions.py b/tests/test_regressions.py index 15ac9ee9..2265f363 100644 --- a/tests/test_regressions.py +++ b/tests/test_regressions.py @@ -454,6 +454,14 @@ def test_primary_key_issue740(): assert p.tokens[0].ttype == T.Keyword +def test_materialized_view_issue752(): + p = sqlparse.parse('CREATE MATERIALIZED VIEW v AS SELECT 1')[0] + assert p.tokens[2].ttype == T.Keyword + formatted = sqlparse.format('create materialized view v as select 1', + keyword_case='upper') + assert formatted == 'CREATE MATERIALIZED VIEW v AS SELECT 1' + + @pytest.fixture def limit_recursion(): curr_limit = sys.getrecursionlimit()