From a33dfd18ecf805fc1dbeaf272ab85d88cdf7dcf1 Mon Sep 17 00:00:00 2001 From: Rafa de la Torre Date: Thu, 19 Nov 2015 15:44:51 +0100 Subject: [PATCH 1/3] Use function return_type instead of hardcoded Geometry --- client/templates/30_plproxy_functions.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/templates/30_plproxy_functions.erb b/client/templates/30_plproxy_functions.erb index 22d6ffc..f6d01dd 100644 --- a/client/templates/30_plproxy_functions.erb +++ b/client/templates/30_plproxy_functions.erb @@ -1,5 +1,5 @@ CREATE OR REPLACE FUNCTION <%= GEOCODER_CLIENT_SCHEMA %>._<%= name %> (user_id name, tx_id bigint, <%= params_with_type %>) -RETURNS Geometry AS $$ +RETURNS <%= return_type %> AS $$ CONNECT <%= GEOCODER_CLIENT_SCHEMA %>._server_conn_str(); SELECT cdb_geocoder_server.<%= name %> (user_id, tx_id, <%= params %>); $$ LANGUAGE plproxy; From d0a43507aeb8471ef38a63d82aa8ee145fe91f22 Mon Sep 17 00:00:00 2001 From: Rafa de la Torre Date: Thu, 19 Nov 2015 15:50:57 +0100 Subject: [PATCH 2/3] Fix typo in comment --- sql-template-renderer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-template-renderer b/sql-template-renderer index 526bd89..8a1e472 100755 --- a/sql-template-renderer +++ b/sql-template-renderer @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # A script to automatically generate SQL files from an interface definition. -# To be called like this: sql-template-renderer interface.csv templates/sql-template.erb +# To be called like this: sql-template-renderer interface.yaml sql-template.erb require 'yaml' require 'erb' From b85cb99011212595300a27fce7737b1617970298 Mon Sep 17 00:00:00 2001 From: Rafa de la Torre Date: Thu, 19 Nov 2015 15:51:24 +0100 Subject: [PATCH 3/3] Rename @f to @function_signature for clarity --- sql-template-renderer | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sql-template-renderer b/sql-template-renderer index 8a1e472..7e11447 100755 --- a/sql-template-renderer +++ b/sql-template-renderer @@ -11,7 +11,7 @@ class SqlTemplateRenderer GEOCODER_CLIENT_SCHEMA = 'cdb_geocoder_client' def initialize(template_file, function_signature) - @f = function_signature + @function_signature = function_signature @template = File.read(template_file) end @@ -20,19 +20,19 @@ class SqlTemplateRenderer end def name - @f['name'] + @function_signature['name'] end def return_type - @f['return_type'] + @function_signature['return_type'] end def params - @f['params'].map { |p| p['name'] }.join(', ') + @function_signature['params'].map { |p| p['name'] }.join(', ') end def params_with_type - @f['params'].map { |p| "#{p['name']} #{p['type']}"}.join(', ') + @function_signature['params'].map { |p| "#{p['name']} #{p['type']}"}.join(', ') end end