summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sqlparse/engine/filter.py6
-rw-r--r--tests/test_split.py7
2 files changed, 10 insertions, 3 deletions
diff --git a/sqlparse/engine/filter.py b/sqlparse/engine/filter.py
index 08ff21d..0f6eec0 100644
--- a/sqlparse/engine/filter.py
+++ b/sqlparse/engine/filter.py
@@ -41,17 +41,17 @@ class StatementFilter(TokenFilter):
return 0
# ANSI
- if ttype is not T.Keyword:
+ if ttype not in T.Keyword:
return 0
unified = value.upper()
- if unified == 'DECLARE':
+ if unified == 'DECLARE' and self._is_create:
self._in_declare = True
return 1
if unified == 'BEGIN':
- if self._in_declare:
+ if self._in_declare: # FIXME(andi): This makes no sense.
return 0
return 0
diff --git a/tests/test_split.py b/tests/test_split.py
index 5146bcb..50b3a6b 100644
--- a/tests/test_split.py
+++ b/tests/test_split.py
@@ -1,3 +1,4 @@
+
# -*- coding: utf-8 -*-
# Tests splitting functions.
@@ -86,3 +87,9 @@ class SQLSplitTest(TestCaseBase):
'comment on table actor is \'The actor table.\';')
stmts = sqlparse.split(sql)
self.assertEqual(len(stmts), 2)
+
+ def test_cursor_declare(self):
+ sql = ('DECLARE CURSOR "foo" AS SELECT 1;\n'
+ 'SELECT 2;')
+ stmts = sqlparse.split(sql)
+ self.assertEqual(len(stmts), 2)