diff options
author | Andreas Albrecht <andreas.albrecht@prounix.de> | 2009-10-22 13:43:38 +0200 |
---|---|---|
committer | Andreas Albrecht <andreas.albrecht@prounix.de> | 2009-10-22 13:43:38 +0200 |
commit | acea845a7f77158bb12d9e35ff56698d769ad947 (patch) | |
tree | 8cecbb6115e54f160382c97a05ffc1718eddead0 /sqlparse/sql.py | |
parent | b4fe0f2e8aece1a5eb8d6d5260dd092c48ac6a46 (diff) | |
download | sqlparse-acea845a7f77158bb12d9e35ff56698d769ad947.tar.gz |
Improved case detection for CASE structures without WHEN in first case.
Diffstat (limited to 'sqlparse/sql.py')
-rw-r--r-- | sqlparse/sql.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sqlparse/sql.py b/sqlparse/sql.py index 195696e..a28cf8b 100644 --- a/sqlparse/sql.py +++ b/sqlparse/sql.py @@ -471,9 +471,12 @@ class Case(TokenList): If an ELSE exists condition is None. """ ret = [] - in_condition = in_value = False + in_value = False + in_condition = True for token in self.tokens: - if token.match(T.Keyword, 'WHEN'): + if token.match(T.Keyword, 'CASE'): + continue + elif token.match(T.Keyword, 'WHEN'): ret.append(([], [])) in_condition = True in_value = False @@ -487,6 +490,9 @@ class Case(TokenList): elif token.match(T.Keyword, 'END'): in_condition = False in_value = False + if (in_condition or in_value) and not ret: + # First condition withou preceding WHEN + ret.append(([], [])) if in_condition: ret[-1][0].append(token) elif in_value: |