diff options
| author | Andi Albrecht <albrecht.andi@gmail.com> | 2013-09-28 08:40:31 +0200 |
|---|---|---|
| committer | Andi Albrecht <albrecht.andi@gmail.com> | 2013-09-28 08:40:31 +0200 |
| commit | f4a152924fc6df8f42c9006f9f07aa3d26d78e82 (patch) | |
| tree | 249e179f0cafbfbfaa6b6cd6264f3d2558a7d538 /tests | |
| parent | 3df9bf4054d6dff589a50225d87be11fa4817c2e (diff) | |
| download | sqlparse-f4a152924fc6df8f42c9006f9f07aa3d26d78e82.tar.gz | |
Fix tagging of identifiers by not taking single quoted strings into account (fixes #111).
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_grouping.py | 11 | ||||
| -rw-r--r-- | tests/test_parse.py | 12 |
2 files changed, 19 insertions, 4 deletions
diff --git a/tests/test_grouping.py b/tests/test_grouping.py index 2b7cefd..fe6aa7d 100644 --- a/tests/test_grouping.py +++ b/tests/test_grouping.py @@ -236,10 +236,13 @@ def test_identifier_with_op_trailing_ws(): 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) +# This test seems to be wrong. It was introduced when fixing #53, but #111 +# showed that this shouldn't be an identifier at all. I'm leaving this +# commented in the source for a while. +# def test_identifier_string_concat(): +# p = sqlparse.parse('\'foo\' || bar')[0] +# assert len(p.tokens) == 1 +# assert isinstance(p.tokens[0], sql.Identifier) def test_identifier_consumes_ordering(): # issue89 diff --git a/tests/test_parse.py b/tests/test_parse.py index 953a237..ea29f88 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -157,3 +157,15 @@ def test_scientific_numbers(num): p = sqlparse.parse(num)[0].tokens assert len(p) == 1 assert p[0].ttype is T.Number.Float + + +def test_single_quotes_are_strings(): + p = sqlparse.parse("'foo'")[0].tokens + assert len(p) == 1 + assert p[0].ttype is T.String.Single + + +def test_double_quotes_are_identifiers(): + p = sqlparse.parse('"foo"')[0].tokens + assert len(p) == 1 + assert isinstance(p[0], sqlparse.sql.Identifier) |
