sogis / gretl-v1

Contains custom gradle tasks to use in gradle builds. The custom tasks extend gradle for use as a sql-centric (geo)data etl. gretl = gradle etl
MIT License
1 stars 2 forks source link

double dollar sign syntax does not work #137

Open edigonzales opened 6 years ago

edigonzales commented 6 years ago

CREATE OR REPLACE FUNCTION ${schema_name}.interpolateZValue(p geometry, p0 geometry, p1 geometry, p2 geometry) RETURNS double precision AS $$ BEGIN return 0.0 END; $$ LANGUAGE plpgsql;

Does not work since it removes one dollar sign for substituting ${schema_name}. Ugly workaround: use single quote style. -> fix sql parameter substitution in gretl (e.g. ignore 2 following dollar signs)

claeis commented 6 years ago

That's not a bug, that's a feature... Because the $ is used a param start character, you have to duplicate it, if you want to have a $ in your sql text. (Any character other than { should also work)

claeis commented 6 years ago

Use dollar quoting with a tag (https://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-DOLLAR-QUOTING).

edigonzales commented 6 years ago

Aaah, the problem is actually not the the dollar but the semicolon in my sql:

CREATE OR REPLACE FUNCTION fubar RETURNS double precision AS $function$ DECLARE x0 DOUBLE PRECISION; y0 DOUBLE PRECISION; ....

ehisqlgen assumes (I guess) that the sql statement ends after first semicolon.