Skip to content

Commit

Permalink
Fix parsing of PRIMARY KEY (fixes #740).
Browse files Browse the repository at this point in the history
  • Loading branch information
andialbrecht committed Mar 16, 2024
1 parent fc4b0be commit 46971e5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ Bug Fixes
* Fix parsing of nested order clauses (issue745, pr746 by john-bodley).
* Thread-safe initialization of Lexer class (issue730).
* Classify TRUNCATE as DDL and GRANT/REVOKE as DCL keywords (based on pr719
by josuc1, thanks for bringing this up!)
by josuc1, thanks for bringing this up!).
* Fix parsing of PRIMARY KEY (issue740).


Release 0.4.4 (Apr 18, 2023)
Expand Down
1 change: 1 addition & 0 deletions sqlparse/keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
(r'DOUBLE\s+PRECISION\b', tokens.Name.Builtin),
(r'GROUP\s+BY\b', tokens.Keyword),
(r'ORDER\s+BY\b', tokens.Keyword),
(r'PRIMARY\s+KEY\b', tokens.Keyword),
(r'HANDLER\s+FOR\b', tokens.Keyword),
(r'GO(\s\d+)\b', tokens.Keyword),
(r'(LATERAL\s+VIEW\s+)'
Expand Down
6 changes: 6 additions & 0 deletions tests/test_regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,3 +444,9 @@ def test_copy_issue672():
p = sqlparse.parse('select * from foo')[0]
copied = copy.deepcopy(p)
assert str(p) == str(copied)


def test_primary_key_issue740():
p = sqlparse.parse('PRIMARY KEY')[0]
assert len(p.tokens) == 1
assert p.tokens[0].ttype == T.Keyword

0 comments on commit 46971e5

Please sign in to comment.