Skip to content

Commit 46971e5

Browse files
committed
Fix parsing of PRIMARY KEY (fixes #740).
1 parent fc4b0be commit 46971e5

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

CHANGELOG

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ Bug Fixes
2323
* Fix parsing of nested order clauses (issue745, pr746 by john-bodley).
2424
* Thread-safe initialization of Lexer class (issue730).
2525
* Classify TRUNCATE as DDL and GRANT/REVOKE as DCL keywords (based on pr719
26-
by josuc1, thanks for bringing this up!)
26+
by josuc1, thanks for bringing this up!).
27+
* Fix parsing of PRIMARY KEY (issue740).
2728

2829

2930
Release 0.4.4 (Apr 18, 2023)

sqlparse/keywords.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
(r'DOUBLE\s+PRECISION\b', tokens.Name.Builtin),
7878
(r'GROUP\s+BY\b', tokens.Keyword),
7979
(r'ORDER\s+BY\b', tokens.Keyword),
80+
(r'PRIMARY\s+KEY\b', tokens.Keyword),
8081
(r'HANDLER\s+FOR\b', tokens.Keyword),
8182
(r'GO(\s\d+)\b', tokens.Keyword),
8283
(r'(LATERAL\s+VIEW\s+)'

tests/test_regressions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,3 +444,9 @@ def test_copy_issue672():
444444
p = sqlparse.parse('select * from foo')[0]
445445
copied = copy.deepcopy(p)
446446
assert str(p) == str(copied)
447+
448+
449+
def test_primary_key_issue740():
450+
p = sqlparse.parse('PRIMARY KEY')[0]
451+
assert len(p.tokens) == 1
452+
assert p.tokens[0].ttype == T.Keyword

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy