summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndi Albrecht <albrecht.andi@gmail.com>2009-09-12 08:05:34 +0200
committerAndi Albrecht <albrecht.andi@gmail.com>2009-09-12 08:05:34 +0200
commit3d13c5d4bb14f76d407285f2a91e7061585fd6da (patch)
tree8816cdae40c231eb4da4c4ae8d49befb1f05e854 /tests
parent29590e09223ca9eb44e15429488664cff9db5f9e (diff)
downloadsqlparse-3d13c5d4bb14f76d407285f2a91e7061585fd6da.tar.gz
Prevent WHERE grouper from consuming closing parenthesis (fixes issue9, reported by estama).
Diffstat (limited to 'tests')
-rw-r--r--tests/test_grouping.py2
-rw-r--r--tests/test_regressions.py20
2 files changed, 21 insertions, 1 deletions
diff --git a/tests/test_grouping.py b/tests/test_grouping.py
index c3039b8..119f574 100644
--- a/tests/test_grouping.py
+++ b/tests/test_grouping.py
@@ -114,7 +114,7 @@ class TestGrouping(TestCaseBase):
s = 'select x from (select y from foo where bar = 1) z'
p = sqlparse.parse(s)[0]
self.ndiffAssertEqual(s, p.to_unicode())
- self.assertTrue(isinstance(p.tokens[-3].tokens[-1], Where))
+ self.assertTrue(isinstance(p.tokens[-3].tokens[-2], Where))
def test_typecast(self):
s = 'select foo::integer from bar'
diff --git a/tests/test_regressions.py b/tests/test_regressions.py
new file mode 100644
index 0000000..41ca531
--- /dev/null
+++ b/tests/test_regressions.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+
+import sqlparse
+from sqlparse import tokens as T
+from sqlparse.engine.grouping import *
+
+from tests.utils import TestCaseBase
+
+
+class TestRegression(TestCaseBase):
+
+ def test_where_doesnt_consume_parenthesis(self): # issue9
+ p = sqlparse.parse('(where 1)')[0]
+ self.assert_(isinstance(p, Statement))
+ self.assertEqual(len(p.tokens), 1)
+ self.assert_(isinstance(p.tokens[0], Parenthesis))
+ prt = p.tokens[0]
+ self.assertEqual(len(prt.tokens), 3)
+ self.assertEqual(prt.tokens[0].ttype, T.Punctuation)
+ self.assertEqual(prt.tokens[-1].ttype, T.Punctuation)