From 454f80d80f6fb98da9b9e5e9fcf10bf15207f3d9 Mon Sep 17 00:00:00 2001 From: Shen Longxing Date: Fri, 18 Dec 2015 15:29:33 +0800 Subject: [PATCH 1/3] fix issue #215 Add keyword 'WHILE' --- sqlparse/keywords.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sqlparse/keywords.py b/sqlparse/keywords.py index 1595aa89..b3bda861 100644 --- a/sqlparse/keywords.py +++ b/sqlparse/keywords.py @@ -565,6 +565,7 @@ 'AS': tokens.Keyword, 'ELSE': tokens.Keyword, 'FOR': tokens.Keyword, + 'WHILE': tokens.Keyword, 'CASE': tokens.Keyword, 'WHEN': tokens.Keyword, From d7201a14ad7a8876079a31f7b7281ddf5ac47b94 Mon Sep 17 00:00:00 2001 From: Shen Longxing Date: Fri, 18 Dec 2015 15:34:52 +0800 Subject: [PATCH 2/3] fix issue #215 Add token for 'END WHILE' --- sqlparse/lexer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlparse/lexer.py b/sqlparse/lexer.py index d0f8e3b3..7dd013ea 100644 --- a/sqlparse/lexer.py +++ b/sqlparse/lexer.py @@ -201,7 +201,7 @@ class _Lexer(object): (r'(? Date: Fri, 18 Dec 2015 15:38:26 +0800 Subject: [PATCH 3/3] fix issue #215 Add splitlevel for while/end while --- sqlparse/engine/filter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sqlparse/engine/filter.py b/sqlparse/engine/filter.py index 149db581..360ff9b6 100644 --- a/sqlparse/engine/filter.py +++ b/sqlparse/engine/filter.py @@ -51,7 +51,7 @@ def _change_splitlevel(self, ttype, value): return 1 return 0 - if unified in ('END IF', 'END FOR'): + if unified in ('END IF', 'END FOR', 'END WHILE'): return -1 if unified == 'END': @@ -64,7 +64,7 @@ def _change_splitlevel(self, ttype, value): self._is_create = True return 0 - if unified in ('IF', 'FOR') \ + if unified in ('IF', 'FOR', 'WHILE') \ and self._is_create and self._begin_depth > 0: return 1