I am trying to create a PostgreSQL trigger in a Play2.0 database evolution script. The sql code is relatively easy and runs fine in pgAdminIII:
CREATE OR REPLACE FUNCTION update_modified() RETURNS TRIGGER AS $$
BEGIN
NEW.modified = now();
RETURN NEW;
END;
$$ LANGUAGE 'plpgsql';
However, I get an error when running the evolution: ERROR: unterminated dollar-quoted
string at or near "$$ BEGIN NEW.modified = now()". The SQL code seems to get truncated at
the first semicolon encountered in the function. I am using the "9.1-901.jdbc4" JDBC driver for PostgreSQL.
Update:
The code in Evolutions.scala (line 219+) performs a simple split on the ;. Seems to be faulty in the framework itself:
// Execute script
s.sql.split(";").map(_.trim).foreach {
case "" =>
case statement => execute(statement)
}
Any solutions?
;. You need to tell it to run that String as a single statement, not a script. As I don't know that Play framework, I can't tell you how that has to be configured.