From c54a9eb9ccaee53181533386d5bac98b23367de0 Mon Sep 17 00:00:00 2001 From: andrew deryabin Date: Thu, 28 Jun 2018 13:51:51 +0300 Subject: [PATCH 1/2] fix "WITH name" case --- sqlparse/sql.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlparse/sql.py b/sqlparse/sql.py index 4b78a921..9f630954 100644 --- a/sqlparse/sql.py +++ b/sqlparse/sql.py @@ -418,7 +418,7 @@ def get_type(self): if isinstance(token, (Identifier, IdentifierList)): _, dml_keyword = self.token_next(tidx, skip_ws=True) - if dml_keyword.ttype == T.Keyword.DML: + if dml_keyword is not None and dml_keyword.ttype == T.Keyword.DML: return dml_keyword.normalized # Hmm, probably invalid syntax, so return unknown. From ec5a552b02c723df5b93b2c7a5a32fc5dd2bda1e Mon Sep 17 00:00:00 2001 From: andrew deryabin Date: Thu, 28 Jun 2018 15:02:19 +0300 Subject: [PATCH 2/2] fix "WITH name" case (flake8 fix) --- sqlparse/sql.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sqlparse/sql.py b/sqlparse/sql.py index 9f630954..5054128e 100644 --- a/sqlparse/sql.py +++ b/sqlparse/sql.py @@ -418,7 +418,8 @@ def get_type(self): if isinstance(token, (Identifier, IdentifierList)): _, dml_keyword = self.token_next(tidx, skip_ws=True) - if dml_keyword is not None and dml_keyword.ttype == T.Keyword.DML: + if dml_keyword is not None \ + and dml_keyword.ttype == T.Keyword.DML: return dml_keyword.normalized # Hmm, probably invalid syntax, so return unknown.