diff --git a/client/renderer/interface.yaml b/client/renderer/interface.yaml index 97c7675..80f1642 100644 --- a/client/renderer/interface.yaml +++ b/client/renderer/interface.yaml @@ -321,3 +321,9 @@ params: - { name: geom, type: Geometry } - { name: timespan, type: text, default: 'NULL'} + +- name: obs_dumpversion + return_type: text + no_params: true + params: + - {} diff --git a/client/renderer/sql-template-renderer b/client/renderer/sql-template-renderer index 80a7744..af558d0 100755 --- a/client/renderer/sql-template-renderer +++ b/client/renderer/sql-template-renderer @@ -36,6 +36,10 @@ class SqlTemplateRenderer @function_signature['multi_row'] end + def no_params + @function_signature['no_params'] + end + def user_config_key @function_signature['user_config_key'] end @@ -45,15 +49,15 @@ class SqlTemplateRenderer end def params - @function_signature['params'].map { |p| p['name'] }.join(', ') + @function_signature['params'].reject(&:empty?).map { |p| "#{p['name']}"}.join(', ') end def params_with_type - @function_signature['params'].map { |p| "#{p['name']} #{p['type']}" }.join(', ') + @function_signature['params'].reject(&:empty?).map { |p| "#{p['name']} #{p['type']}" }.join(', ') end def params_with_type_and_default - parameters = @function_signature['params'].map do |p| + parameters = @function_signature['params'].reject(&:empty?).map do |p| if not p['default'].nil? "#{p['name']} #{p['type']} DEFAULT #{p['default']}" else diff --git a/client/renderer/templates/20_public_functions.erb b/client/renderer/templates/20_public_functions.erb index cc79dd8..5de10bd 100644 --- a/client/renderer/templates/20_public_functions.erb +++ b/client/renderer/templates/20_public_functions.erb @@ -25,10 +25,12 @@ BEGIN <% elsif multi_field %> SELECT * FROM <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(username, orgname, <%= params %>) INTO ret; RETURN ret; + <% elsif no_params %> + SELECT * FROM <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(username, orgname) INTO ret; + RETURN ret; <% else %> SELECT <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(username, orgname, <%= params %>) INTO ret; RETURN ret; <% end %> END; $$ LANGUAGE 'plpgsql' SECURITY DEFINER; - diff --git a/client/renderer/templates/30_plproxy_functions.erb b/client/renderer/templates/30_plproxy_functions.erb index b5e117a..66a6727 100644 --- a/client/renderer/templates/30_plproxy_functions.erb +++ b/client/renderer/templates/30_plproxy_functions.erb @@ -1,10 +1,15 @@ +<% if no_params %> +CREATE OR REPLACE FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %> (username text, organization_name text) +<% else %> CREATE OR REPLACE FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %> (username text, organization_name text, <%= params_with_type_and_default %>) +<% end %> RETURNS <%= return_type %> AS $$ CONNECT <%= DATASERVICES_CLIENT_SCHEMA %>._server_conn_str(); <% if multi_field %> SELECT * FROM <%= DATASERVICES_SERVER_SCHEMA %>.<%= name %> (username, organization_name, <%= params %>); + <% elsif no_params %> + SELECT * FROM <%= DATASERVICES_SERVER_SCHEMA %>.<%= name %> (username, organization_name); <% else %> SELECT <%= DATASERVICES_SERVER_SCHEMA %>.<%= name %> (username, organization_name, <%= params %>); <% end %> $$ LANGUAGE plproxy; - diff --git a/server/extension/sql/130_data_observatory_helper.sql b/server/extension/sql/130_data_observatory_helper.sql new file mode 100644 index 0000000..841872c --- /dev/null +++ b/server/extension/sql/130_data_observatory_helper.sql @@ -0,0 +1,5 @@ +CREATE OR REPLACE FUNCTION cdb_dataservices_server.obs_dumpversion(username text, orgname text) +RETURNS text AS $$ + CONNECT cdb_dataservices_server._obs_server_conn_str(username, orgname); + SELECT cdb_observatory.obs_dumpversion(); +$$ LANGUAGE plproxy;