File tree Expand file tree Collapse file tree 4 files changed +48
-1
lines changed
Expand file tree Collapse file tree 4 files changed +48
-1
lines changed Original file line number Diff line number Diff line change 11Development Version
22-------------------
33
4+ Bug Fixes
5+ * Fix parsing error with dollar-quoted procedure bodies (issue83).
6+
47Other
58 * py3k fixes (by vthriller).
69 * py3k fixes in setup.py (by Florian Bauer).
Original file line number Diff line number Diff line change @@ -177,7 +177,7 @@ class Lexer(object):
177177 (r'CASE\b' , tokens .Keyword ), # extended CASE(foo)
178178 (r"`(``|[^`])*`" , tokens .Name ),
179179 (r"´(´´|[^´])*´" , tokens .Name ),
180- (r'\$([^\W\d_ ]\w*)?\$' , tokens .Name .Builtin ),
180+ (r'\$([^\W\d ]\w*)?\$' , tokens .Name .Builtin ),
181181 (r'\?{1}' , tokens .Name .Placeholder ),
182182 (r'[$:?%]\w+' , tokens .Name .Placeholder ),
183183 # FIXME(andi): VALUES shouldn't be listed here
Original file line number Diff line number Diff line change @@ -113,3 +113,24 @@ def test_quoted_identifier():
113113 assert isinstance (t [2 ], sqlparse .sql .Identifier )
114114 assert t [2 ].get_name () == 'z'
115115 assert t [2 ].get_real_name () == 'y'
116+
117+
118+ def test_psql_quotation_marks (): # issue83
119+ # regression: make sure plain $$ work
120+ t = sqlparse .split ("""
121+ CREATE OR REPLACE FUNCTION testfunc1(integer) RETURNS integer AS $$
122+ ....
123+ $$ LANGUAGE plpgsql;
124+ CREATE OR REPLACE FUNCTION testfunc2(integer) RETURNS integer AS $$
125+ ....
126+ $$ LANGUAGE plpgsql;""" )
127+ assert len (t ) == 2
128+ # make sure $SOMETHING$ works too
129+ t = sqlparse .split ("""
130+ CREATE OR REPLACE FUNCTION testfunc1(integer) RETURNS integer AS $PROC_1$
131+ ....
132+ $PROC_1$ LANGUAGE plpgsql;
133+ CREATE OR REPLACE FUNCTION testfunc2(integer) RETURNS integer AS $PROC_2$
134+ ....
135+ $PROC_2$ LANGUAGE plpgsql;""" )
136+ assert len (t ) == 2
Original file line number Diff line number Diff line change @@ -134,3 +134,26 @@ def _get_identifier(sql):
134134 for func_name , result in results :
135135 func = getattr (i , func_name )
136136 assert func () == result
137+
138+
139+ def test_issue83 ():
140+ sql = """
141+ CREATE OR REPLACE FUNCTION func_a(text)
142+ RETURNS boolean LANGUAGE plpgsql STRICT IMMUTABLE AS
143+ $_$
144+ BEGIN
145+ ...
146+ END;
147+ $_$;
148+
149+ CREATE OR REPLACE FUNCTION func_b(text)
150+ RETURNS boolean LANGUAGE plpgsql STRICT IMMUTABLE AS
151+ $_$
152+ BEGIN
153+ ...
154+ END;
155+ $_$;
156+
157+ ALTER TABLE..... ;"""
158+ t = sqlparse .split (sql )
159+ assert len (t ) == 3
You can’t perform that action at this time.
0 commit comments