summaryrefslogtreecommitdiff
path: root/sqlparse
diff options
context:
space:
mode:
authorWilliam Ivanski <william.ivanski@gmail.com>2019-04-16 19:17:10 -0300
committerAndi Albrecht <albrecht.andi@gmail.com>2019-04-17 11:41:14 +0200
commit71fd89b23d6619467634c25dc690c20d6f6b1253 (patch)
tree13fdb24998b7ad418585cc7a8737954d0cf20b9b /sqlparse
parentff8d5982e83bab7023ffc6f3380cb9901be3443a (diff)
downloadsqlparse-71fd89b23d6619467634c25dc690c20d6f6b1253.tar.gz
Fixes #485
Diffstat (limited to 'sqlparse')
-rw-r--r--sqlparse/engine/statement_splitter.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/sqlparse/engine/statement_splitter.py b/sqlparse/engine/statement_splitter.py
index 444b46a..94a8cf6 100644
--- a/sqlparse/engine/statement_splitter.py
+++ b/sqlparse/engine/statement_splitter.py
@@ -19,6 +19,7 @@ class StatementSplitter(object):
"""Set the filter attributes to its default values"""
self._in_declare = False
self._is_create = False
+ self._parenthesis_depth = 0
self._begin_depth = 0
self.consume_ws = False
@@ -27,14 +28,16 @@ class StatementSplitter(object):
def _change_splitlevel(self, ttype, value):
"""Get the new split level (increase, decrease or remain equal)"""
- # ANSI
- # if normal token return
- # wouldn't parenthesis increase/decrease a level?
- # no, inside a parenthesis can't start new statement
- if ttype not in T.Keyword:
+
+ # parenthesis increase/decrease a level
+ if ttype is T.Punctuation and value == '(':
+ return 1
+ elif ttype is T.Punctuation and value == ')':
+ return -1
+ elif ttype not in T.Keyword: # if normal token return
return 0
- # Everything after here is ttype = T.Keyword
+ # Everything after here is ttype = T.Keyword or ttype = T.
# Also to note, once entered an If statement you are done and basically
# returning
unified = value.upper()