diff options
| author | Andi Albrecht <albrecht.andi@gmail.com> | 2016-08-13 17:38:21 +0200 |
|---|---|---|
| committer | Andi Albrecht <albrecht.andi@gmail.com> | 2016-08-13 17:38:21 +0200 |
| commit | 2893bd1857d685cf892beac3a7429d03cf1a09f1 (patch) | |
| tree | 1fc1a427841391137820355f33cdaac119c080b6 /tests/test_parse.py | |
| parent | b7a30d04427e4e4cbc66d08b780ffbb23ab44931 (diff) | |
| download | sqlparse-2893bd1857d685cf892beac3a7429d03cf1a09f1.tar.gz | |
Parse double dollars (PostgreSQL) as literal strings (fixes #277).
Diffstat (limited to 'tests/test_parse.py')
| -rw-r--r-- | tests/test_parse.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/test_parse.py b/tests/test_parse.py index 2d23425..8dd1150 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -384,3 +384,22 @@ def test_stmt_tokens_parents(): stmt = sqlparse.parse(s)[0] for token in stmt.tokens: assert token.has_ancestor(stmt) + + +@pytest.mark.parametrize('sql, is_literal', [ + ('$$foo$$', True), + ('$_$foo$_$', True), + ('$token$ foo $token$', True), + # don't parse inner tokens + ('$_$ foo $token$bar$token$ baz$_$', True), + ('$A$ foo $B$', False) # tokens don't match +]) +def test_dbldollar_as_literal(sql, is_literal): + # see issue 277 + p = sqlparse.parse(sql)[0] + if is_literal: + assert len(p.tokens) == 1 + assert p.tokens[0].ttype == T.Literal + else: + for token in p.tokens: + assert token.ttype != T.Literal |
