summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndi Albrecht <albrecht.andi@gmail.com>2012-12-22 21:32:44 +0100
committerAndi Albrecht <albrecht.andi@gmail.com>2012-12-22 21:32:44 +0100
commit5bc57bda760727bc5459bca9190a1bd893078e79 (patch)
tree576e61f8b69ff0a950d60a52409caa41e52e586b /tests
parent6e8276a8be8c63813ec1f371d670f1aaa25d525c (diff)
downloadsqlparse-5bc57bda760727bc5459bca9190a1bd893078e79.tar.gz
Fix parsing error with dollar-quoted procedure bodies (fixes issue83).
Diffstat (limited to 'tests')
-rw-r--r--tests/test_parse.py21
-rw-r--r--tests/test_regressions.py23
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/test_parse.py b/tests/test_parse.py
index 59b8e72..6c9cfa9 100644
--- a/tests/test_parse.py
+++ b/tests/test_parse.py
@@ -113,3 +113,24 @@ def test_quoted_identifier():
assert isinstance(t[2], sqlparse.sql.Identifier)
assert t[2].get_name() == 'z'
assert t[2].get_real_name() == 'y'
+
+
+def test_psql_quotation_marks(): # issue83
+ # regression: make sure plain $$ work
+ t = sqlparse.split("""
+ CREATE OR REPLACE FUNCTION testfunc1(integer) RETURNS integer AS $$
+ ....
+ $$ LANGUAGE plpgsql;
+ CREATE OR REPLACE FUNCTION testfunc2(integer) RETURNS integer AS $$
+ ....
+ $$ LANGUAGE plpgsql;""")
+ assert len(t) == 2
+ # make sure $SOMETHING$ works too
+ t = sqlparse.split("""
+ CREATE OR REPLACE FUNCTION testfunc1(integer) RETURNS integer AS $PROC_1$
+ ....
+ $PROC_1$ LANGUAGE plpgsql;
+ CREATE OR REPLACE FUNCTION testfunc2(integer) RETURNS integer AS $PROC_2$
+ ....
+ $PROC_2$ LANGUAGE plpgsql;""")
+ assert len(t) == 2
diff --git a/tests/test_regressions.py b/tests/test_regressions.py
index e1c2c89..ba156f0 100644
--- a/tests/test_regressions.py
+++ b/tests/test_regressions.py
@@ -134,3 +134,26 @@ def test_issue78():
for func_name, result in results:
func = getattr(i, func_name)
assert func() == result
+
+
+def test_issue83():
+ sql = """
+CREATE OR REPLACE FUNCTION func_a(text)
+ RETURNS boolean LANGUAGE plpgsql STRICT IMMUTABLE AS
+$_$
+BEGIN
+ ...
+END;
+$_$;
+
+CREATE OR REPLACE FUNCTION func_b(text)
+ RETURNS boolean LANGUAGE plpgsql STRICT IMMUTABLE AS
+$_$
+BEGIN
+ ...
+END;
+$_$;
+
+ALTER TABLE..... ;"""
+ t = sqlparse.split(sql)
+ assert len(t) == 3