Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect splitting of postgres function containing dollar-quoted semicolon #307

Closed
koljonen opened this issue Nov 30, 2016 · 2 comments
Closed

Comments

@koljonen
Copy link
Contributor

In the python console:

>>> sqlparse.split('''CREATE OR REPLACE FUNCTION public.bug() RETURNS text
... LANGUAGE sql
... AS $func$
... select $string$ Run this query: SELECT 123; $string$::text;
... $func$;''')
[u'CREATE OR REPLACE FUNCTION public.bug() RETURNS text\nLANGUAGE sql\nAS $func$\nselect $string$ Run this query: SELECT 123;', u'$string$::text;\n$func$;']

It works as expected with regular quotes:

>>> sqlparse.split('''CREATE OR REPLACE FUNCTION public.bug() RETURNS text
... LANGUAGE sql
... AS $func$
... select ' Run this query: SELECT 123; '::text;
... $func$;''')
[u"CREATE OR REPLACE FUNCTION public.bug() RETURNS text\nLANGUAGE sql\nAS $func$\nselect ' Run this query: SELECT 123; '::text;\n$func$;"]
@proddata
Copy link
Contributor

proddata commented Feb 3, 2024

This seems to be resolved with v0.4.4

>>> sqlparse.split('''CREATE OR REPLACE FUNCTION public.bug() RETURNS text
... LANGUAGE sql
... AS $func$
... select $string$ Run this query: SELECT 123; $string$::text;
... $func$;''')
['CREATE OR REPLACE FUNCTION public.bug() RETURNS text\nLANGUAGE sql\nAS $func$\nselect $string$ Run this query: SELECT 123; $string$::text;\n$func$;']

@andialbrecht
Copy link
Owner

Yepp, this is fixed. Thanks for confirmation @proddata !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants