diff options
| author | Andi Albrecht <albrecht.andi@gmail.com> | 2011-07-25 16:59:44 +0200 |
|---|---|---|
| committer | Andi Albrecht <albrecht.andi@gmail.com> | 2011-07-25 16:59:44 +0200 |
| commit | f7588d5390eaa9fc36b199a5df54fc2c645db3a4 (patch) | |
| tree | 6eb92d99d6b83e8fe6a3db1bce3b50951de4eef5 | |
| parent | de0e6d9cc68048cd9bd42ff6b720dedadfaf1ef7 (diff) | |
| download | sqlparse-f7588d5390eaa9fc36b199a5df54fc2c645db3a4.tar.gz | |
Make sure that stand-alone comments are parsed correctly (fixes issue26).
| -rw-r--r-- | CHANGES | 1 | ||||
| -rw-r--r-- | tests/test_regressions.py | 18 |
2 files changed, 19 insertions, 0 deletions
@@ -13,6 +13,7 @@ Bug Fixes * Relax detection of keywords, esp. when used as function names (issue36, nyuhu...@gmail.com). * Don't treat single characters as keywords (issue32). + * Improve parsing of stand-alone comments (issue26). Release 0.1.2 (Nov 23, 2010) diff --git a/tests/test_regressions.py b/tests/test_regressions.py index edc039f..86b6292 100644 --- a/tests/test_regressions.py +++ b/tests/test_regressions.py @@ -27,6 +27,24 @@ class RegressionTests(TestCaseBase): self.assertEqual(len(parsed), 3) self.assertEqual(str(parsed[1]).strip(), "select 'two\\'';") + def test_issue26(self): + # parse stand-alone comments + p = sqlparse.parse('--hello')[0] + self.assertEqual(len(p.tokens), 1) + self.assert_(p.tokens[0].ttype is T.Comment.Single) + p = sqlparse.parse('-- hello')[0] + self.assertEqual(len(p.tokens), 1) + self.assert_(p.tokens[0].ttype is T.Comment.Single) + p = sqlparse.parse('--hello\n')[0] + self.assertEqual(len(p.tokens), 1) + self.assert_(p.tokens[0].ttype is T.Comment.Single) + p = sqlparse.parse('--')[0] + self.assertEqual(len(p.tokens), 1) + self.assert_(p.tokens[0].ttype is T.Comment.Single) + p = sqlparse.parse('--\n')[0] + self.assertEqual(len(p.tokens), 1) + self.assert_(p.tokens[0].ttype is T.Comment.Single) + def test_issue34(self): t = sqlparse.parse("create")[0].token_first() self.assertEqual(t.match(T.Keyword.DDL, "create"), True) |
