diff options
| author | Andi Albrecht <albrecht.andi@gmail.com> | 2012-11-11 09:48:11 +0100 |
|---|---|---|
| committer | Andi Albrecht <albrecht.andi@gmail.com> | 2012-11-11 09:48:11 +0100 |
| commit | 7af0b13e037fa11de0466f56b1bdc8d9f269cd1c (patch) | |
| tree | 3bb3f35dc3c78c40f44c70ec13e4698264ff1e49 /tests | |
| parent | 4f5f034a1f0699ff9f9b180e9d0d3f79cc69b1d3 (diff) | |
| download | sqlparse-7af0b13e037fa11de0466f56b1bdc8d9f269cd1c.tar.gz | |
Handle whitepaces between operators correctly, improve handling of concatenated strings (issue53).
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_grouping.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/test_grouping.py b/tests/test_grouping.py index c63d8e5..345e62f 100644 --- a/tests/test_grouping.py +++ b/tests/test_grouping.py @@ -192,7 +192,7 @@ class TestGrouping(TestCaseBase): def test_varchar(self): p = sqlparse.parse('"text" Varchar(50) NOT NULL')[0] self.assert_(isinstance(p.tokens[2], sql.Function)) - + class TestStatement(TestCaseBase): @@ -207,3 +207,27 @@ class TestStatement(TestCaseBase): # are parsed as two statements where later only consists of the # trailing whitespace. self.assertEqual(f('\n').get_type(), 'UNKNOWN') + + +def test_identifier_with_operators(): # issue 53 + p = sqlparse.parse('foo||bar')[0] + assert len(p.tokens) == 1 + assert isinstance(p.tokens[0], sql.Identifier) + # again with whitespaces + p = sqlparse.parse('foo || bar')[0] + assert len(p.tokens) == 1 + assert isinstance(p.tokens[0], sql.Identifier) + + +def test_identifier_with_op_trailing_ws(): + # make sure trailing whitespace isn't grouped with identifier + p = sqlparse.parse('foo || bar ')[0] + assert len(p.tokens) == 2 + assert isinstance(p.tokens[0], sql.Identifier) + assert p.tokens[1].ttype is T.Whitespace + + +def test_identifier_string_concat(): + p = sqlparse.parse('\'foo\' || bar')[0] + assert len(p.tokens) == 1 + assert isinstance(p.tokens[0], sql.Identifier) |
