diff options
author | Andi Albrecht <albrecht.andi@googlemail.com> | 2010-02-18 09:58:12 +0100 |
---|---|---|
committer | Andi Albrecht <albrecht.andi@googlemail.com> | 2010-02-18 09:58:12 +0100 |
commit | fac431b15799fd9561346efcc128e0b5e8aec3d0 (patch) | |
tree | 62826ad30314673bdba618f690d726c380db121b /sqlparse/sql.py | |
parent | ed2d2549f846a04d13be33a4971a4e4a0089914f (diff) | |
download | sqlparse-fac431b15799fd9561346efcc128e0b5e8aec3d0.tar.gz |
Fix an issue with trailing whitespaces (reported by Kris).
Diffstat (limited to 'sqlparse/sql.py')
-rw-r--r-- | sqlparse/sql.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/sqlparse/sql.py b/sqlparse/sql.py index a28cf8b..cc4f434 100644 --- a/sqlparse/sql.py +++ b/sqlparse/sql.py @@ -323,7 +323,11 @@ class Statement(TokenList): isn't a DML or DDL keyword "UNKNOWN" is returned. """ first_token = self.token_first() - if first_token.ttype in (T.Keyword.DML, T.Keyword.DDL): + if first_token is None: + # An "empty" statement that either has not tokens at all + # or only whitespace tokens. + return 'UNKNOWN' + elif first_token.ttype in (T.Keyword.DML, T.Keyword.DDL): return first_token.value.upper() else: return 'UNKNOWN' |