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

Evolutions treat PLPGSQL dolar sign as comment #8326

Closed
eximius313 opened this issue Apr 2, 2018 · 4 comments
Closed

Evolutions treat PLPGSQL dolar sign as comment #8326

eximius313 opened this issue Apr 2, 2018 · 4 comments

Comments

@eximius313
Copy link

Play Version (2.5.x / etc)

2.6.11

API (Scala / Java / Neither / Both)

N/A

Operating System (Ubuntu 15.10 / MacOS 10.10 / Windows 10)

Windows 7

JDK (Oracle 1.8.0_72, OpenJDK 1.8.x, Azul Zing)

JDK 9.0.4

Library Dependencies

Postgres 9.3.6

Expected Behavior

I can use PLPGSQL in evolution script

Actual Behavior

Play throws:

We got the following error: Unterminated dollar quote started at position 60 in SQL CREATE OR REPLACE FUNCTION do_something() RETURNS trigger AS $$ BEGIN PERFORM some_action(OLD.my_id); RETURN OLD; END. Expected terminating $$ [ERROR:0, SQLSTATE:42601], while trying to run this SQL script:
CREATE OR REPLACE FUNCTION do_something() RETURNS trigger AS $$
BEGIN
   PERFORM some_action(OLD.my_id);
   RETURN OLD;
END;
$$ LANGUAGE plpgsql;

Of course the query has valid structure and works fine in Postgres.
I also tried with and without escaping ; as documentation says

@mkurz
Copy link
Member

mkurz commented Apr 2, 2018

I also tried with and without escaping ;

Can you show us what that PL/pgSQL code looked like?

@eximius313
Copy link
Author

without:

CREATE OR REPLACE FUNCTION do_something() RETURNS trigger AS $$
BEGIN
   PERFORM some_action(OLD.my_id);
   RETURN OLD;
END;
$$ LANGUAGE plpgsql;

with:

CREATE OR REPLACE FUNCTION do_something() RETURNS trigger AS $$
BEGIN
   PERFORM some_action(OLD.my_id);;
   RETURN OLD;;
END;
$$ LANGUAGE plpgsql;

@mkurz
Copy link
Member

mkurz commented Apr 2, 2018

@eximius313 I think you missed to escape the ; after the END:

CREATE OR REPLACE FUNCTION do_something() RETURNS trigger AS $$
BEGIN
   PERFORM some_action(OLD.my_id);;
   RETURN OLD;;
END;;
$$ LANGUAGE plpgsql;

@eximius313
Copy link
Author

OMG, you are right!
Sorry for confusion

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

2 participants