File tree Expand file tree Collapse file tree 3 files changed +11
-2
lines changed
Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ Bug Fixes
66 reported and initial patch by andyboyko).
77 * Stricter detection of identfier aliases (issue8, reported by estama).
88 * WHERE grouping consumed closing parenthesis (issue9, reported by estama).
9+ * Fixed an issue with trailing whitespaces (reported by Kris).
910
1011
1112Release 0.1.1 (May 6, 2009)
2526
2627Release 0.1.0 (Apr 8, 2009)
2728---------------------------
28- * Initial release.
29+ * Initial release.
Original file line number Diff line number Diff line change @@ -323,7 +323,11 @@ def get_type(self):
323323 isn't a DML or DDL keyword "UNKNOWN" is returned.
324324 """
325325 first_token = self .token_first ()
326- if first_token .ttype in (T .Keyword .DML , T .Keyword .DDL ):
326+ if first_token is None :
327+ # An "empty" statement that either has not tokens at all
328+ # or only whitespace tokens.
329+ return 'UNKNOWN'
330+ elif first_token .ttype in (T .Keyword .DML , T .Keyword .DDL ):
327331 return first_token .value .upper ()
328332 else :
329333 return 'UNKNOWN'
Original file line number Diff line number Diff line change @@ -176,3 +176,7 @@ def test_get_type(self):
176176 self .assertEqual (f (' update foo' ).get_type (), 'UPDATE' )
177177 self .assertEqual (f ('\n update foo' ).get_type (), 'UPDATE' )
178178 self .assertEqual (f ('foo' ).get_type (), 'UNKNOWN' )
179+ # Statements that have a whitespace after the closing semicolon
180+ # are parsed as two statements where later only consists of the
181+ # trailing whitespace.
182+ self .assertEqual (f ('\n ' ).get_type (), 'UNKNOWN' )
You can’t perform that action at this time.
0 commit comments