不要怂,就是干,撸起袖子干!

Commit 29b6a547 by mickael couzinet

Change postgres delimiter

Hi,

Actually the postgres delimiter for define a function is $$.
An error are returned if we have this delimiter in the query ('joey bada$$' for example)

So I propose to change the delimiter $$ to $func$ which is less common
1 parent 642fbbd2
Showing with 3 additions and 3 deletions
......@@ -281,7 +281,7 @@ module.exports = (function() {
language = language || 'plpgsql';
returns = returns || 'SETOF ' + this.quoteTable(tableName);
var query = 'CREATE OR REPLACE FUNCTION pg_temp.<%= fnName %>() RETURNS <%= returns %> AS $$ BEGIN <%= body %> END; $$ LANGUAGE <%= language %>; SELECT * FROM pg_temp.<%= fnName %>();';
var query = 'CREATE OR REPLACE FUNCTION pg_temp.<%= fnName %>() RETURNS <%= returns %> AS $func$ BEGIN <%= body %> END; $func$ LANGUAGE <%= language %>; SELECT * FROM pg_temp.<%= fnName %>();';
return Utils._.template(query)({
fnName: fnName,
......@@ -600,11 +600,11 @@ module.exports = (function() {
createFunction: function(functionName, params, returnType, language, body, options) {
var sql = ['CREATE FUNCTION <%= functionName %>(<%= paramList %>)'
, 'RETURNS <%= returnType %> AS $$'
, 'RETURNS <%= returnType %> AS $func$'
, 'BEGIN'
, '\t<%= body %>'
, 'END;'
, "$$ language '<%= language %>'<%= options %>;"
, "$func$ language '<%= language %>'<%= options %>;"
].join('\n');
return Utils._.template(sql)({
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!