Remove the no_params from client generator #302
This commit is contained in:
parent
37a3214f67
commit
f07d2f9302
@ -323,7 +323,6 @@
|
|||||||
|
|
||||||
- name: obs_dumpversion
|
- name: obs_dumpversion
|
||||||
return_type: text
|
return_type: text
|
||||||
no_params: true
|
|
||||||
params:
|
params:
|
||||||
- {}
|
- {}
|
||||||
|
|
||||||
@ -381,7 +380,6 @@
|
|||||||
- name: cdb_service_params
|
- name: cdb_service_params
|
||||||
return_type: SETOF cdb_dataservices_client.service_params
|
return_type: SETOF cdb_dataservices_client.service_params
|
||||||
multi_row: true
|
multi_row: true
|
||||||
no_params: true
|
|
||||||
params:
|
params:
|
||||||
- {}
|
- {}
|
||||||
|
|
||||||
|
@ -36,10 +36,6 @@ class SqlTemplateRenderer
|
|||||||
@function_signature['multi_row']
|
@function_signature['multi_row']
|
||||||
end
|
end
|
||||||
|
|
||||||
def no_params
|
|
||||||
@function_signature['no_params']
|
|
||||||
end
|
|
||||||
|
|
||||||
def user_config_key
|
def user_config_key
|
||||||
@function_signature['user_config_key']
|
@function_signature['user_config_key']
|
||||||
end
|
end
|
||||||
@ -49,11 +45,11 @@ class SqlTemplateRenderer
|
|||||||
end
|
end
|
||||||
|
|
||||||
def params
|
def params
|
||||||
@function_signature['params'].reject(&:empty?).map { |p| "#{p['name']}"}.join(', ')
|
@function_signature['params'].reject(&:empty?).map { |p| "#{p['name']}"}
|
||||||
end
|
end
|
||||||
|
|
||||||
def params_with_type
|
def params_with_type
|
||||||
@function_signature['params'].reject(&:empty?).map { |p| "#{p['name']} #{p['type']}" }.join(', ')
|
@function_signature['params'].reject(&:empty?).map { |p| "#{p['name']} #{p['type']}" }
|
||||||
end
|
end
|
||||||
|
|
||||||
def params_with_type_and_default
|
def params_with_type_and_default
|
||||||
@ -64,7 +60,7 @@ class SqlTemplateRenderer
|
|||||||
"#{p['name']} #{p['type']}"
|
"#{p['name']} #{p['type']}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return parameters.join(', ')
|
return parameters
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
-- These are the only ones with permissions to publicuser role
|
-- These are the only ones with permissions to publicuser role
|
||||||
-- and should also be the only ones with SECURITY DEFINER
|
-- and should also be the only ones with SECURITY DEFINER
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>.<%= name %> (<%= params_with_type_and_default %>)
|
CREATE OR REPLACE FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>.<%= name %> (<%= params_with_type_and_default.join(' ,') %>)
|
||||||
RETURNS <%= return_type %> AS $$
|
RETURNS <%= return_type %> AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
<% if not multi_row %>ret <%= return_type %>;<% end %>
|
<% if not multi_row %>ret <%= return_type %>;<% end %>
|
||||||
@ -21,15 +21,12 @@ BEGIN
|
|||||||
END IF;
|
END IF;
|
||||||
<% if multi_row %>
|
<% if multi_row %>
|
||||||
RETURN QUERY
|
RETURN QUERY
|
||||||
SELECT * FROM <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(username, orgname, <%= params %>);
|
SELECT * FROM <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(<%= ['username', 'orgname'].concat(params).join(', ') %>);
|
||||||
<% elsif multi_field %>
|
<% elsif multi_field %>
|
||||||
SELECT * FROM <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(username, orgname, <%= params %>) INTO ret;
|
SELECT * FROM <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(<%= ['username', 'orgname'].concat(params).join(', ') %>) INTO ret;
|
||||||
RETURN ret;
|
|
||||||
<% elsif no_params %>
|
|
||||||
SELECT * FROM <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(username, orgname) INTO ret;
|
|
||||||
RETURN ret;
|
RETURN ret;
|
||||||
<% else %>
|
<% else %>
|
||||||
SELECT <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(username, orgname, <%= params %>) INTO ret;
|
SELECT <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(<%= ['username', 'orgname'].concat(params).join(', ') %>) INTO ret;
|
||||||
RETURN ret;
|
RETURN ret;
|
||||||
<% end %>
|
<% end %>
|
||||||
END;
|
END;
|
||||||
|
@ -1,15 +1,9 @@
|
|||||||
<% if no_params %>
|
CREATE OR REPLACE FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %> (<%= ['username text', 'organization_name text'].concat(params_with_type_and_default).join(', ') %>)
|
||||||
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 $$
|
RETURNS <%= return_type %> AS $$
|
||||||
CONNECT <%= DATASERVICES_CLIENT_SCHEMA %>._server_conn_str();
|
CONNECT <%= DATASERVICES_CLIENT_SCHEMA %>._server_conn_str();
|
||||||
<% if multi_field %>
|
<% if multi_field %>
|
||||||
SELECT * FROM <%= DATASERVICES_SERVER_SCHEMA %>.<%= name %> (username, organization_name, <%= params %>);
|
SELECT * FROM <%= DATASERVICES_SERVER_SCHEMA %>.<%= name %> (<%= ['username', 'organization_name'].concat(params).join(', ') %>);
|
||||||
<% elsif no_params %>
|
|
||||||
SELECT * FROM <%= DATASERVICES_SERVER_SCHEMA %>.<%= name %> (username, organization_name);
|
|
||||||
<% else %>
|
<% else %>
|
||||||
SELECT <%= DATASERVICES_SERVER_SCHEMA %>.<%= name %> (username, organization_name, <%= params %>);
|
SELECT <%= DATASERVICES_SERVER_SCHEMA %>.<%= name %> (<%= ['username', 'organization_name'].concat(params).join(', ') %>);
|
||||||
<% end %>
|
<% end %>
|
||||||
$$ LANGUAGE plproxy;
|
$$ LANGUAGE plproxy;
|
||||||
|
@ -1 +1 @@
|
|||||||
GRANT EXECUTE ON FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>.<%= name %>(<%= params_with_type %>) TO publicuser;
|
GRANT EXECUTE ON FUNCTION <%= DATASERVICES_CLIENT_SCHEMA %>.<%= name %>(<%= params_with_type.join(', ') %>) TO publicuser;
|
||||||
|
Loading…
Reference in New Issue
Block a user