Dont use the defaults in the grant script

This commit is contained in:
Mario de Frutos 2016-01-22 10:55:07 +01:00
parent 49941a78f3
commit 7cce491a13
4 changed files with 7 additions and 4 deletions

View File

@ -7,4 +7,4 @@ GRANT EXECUTE ON FUNCTION cdb_geocoder_client.cdb_geocode_namedplace_point(city_
GRANT EXECUTE ON FUNCTION cdb_geocoder_client.cdb_geocode_postalcode_polygon(postal_code text, country_name text) TO publicuser; GRANT EXECUTE ON FUNCTION cdb_geocoder_client.cdb_geocode_postalcode_polygon(postal_code text, country_name text) TO publicuser;
GRANT EXECUTE ON FUNCTION cdb_geocoder_client.cdb_geocode_postalcode_point(postal_code text, country_name text) TO publicuser; GRANT EXECUTE ON FUNCTION cdb_geocoder_client.cdb_geocode_postalcode_point(postal_code text, country_name text) TO publicuser;
GRANT EXECUTE ON FUNCTION cdb_geocoder_client.cdb_geocode_ipaddress_point(ip_address text) TO publicuser; GRANT EXECUTE ON FUNCTION cdb_geocoder_client.cdb_geocode_ipaddress_point(ip_address text) TO publicuser;
GRANT EXECUTE ON FUNCTION cdb_geocoder_client.cdb_geocode_street_point(searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL) TO publicuser; GRANT EXECUTE ON FUNCTION cdb_geocoder_client.cdb_geocode_street_point(searchtext text, city text, state_province text, country text) TO publicuser;

View File

@ -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 <%= GEOCODER_CLIENT_SCHEMA %>.<%= name %> (<%= params_with_type %>) CREATE OR REPLACE FUNCTION <%= GEOCODER_CLIENT_SCHEMA %>.<%= name %> (<%= params_with_type_and_default %>)
RETURNS <%= return_type %> AS $$ RETURNS <%= return_type %> AS $$
DECLARE DECLARE
ret <%= return_type %>; ret <%= return_type %>;

View File

@ -1,4 +1,4 @@
CREATE OR REPLACE FUNCTION <%= GEOCODER_CLIENT_SCHEMA %>._<%= name %> (username text, organization_name text, <%= params_with_type %>) CREATE OR REPLACE FUNCTION <%= GEOCODER_CLIENT_SCHEMA %>._<%= name %> (username text, organization_name text, <%= params_with_type_and_default %>)
RETURNS <%= return_type %> AS $$ RETURNS <%= return_type %> AS $$
CONNECT <%= GEOCODER_CLIENT_SCHEMA %>._server_conn_str(); CONNECT <%= GEOCODER_CLIENT_SCHEMA %>._server_conn_str();
SELECT cdb_geocoder_server.<%= name %> (username, organization_name, <%= params %>); SELECT cdb_geocoder_server.<%= name %> (username, organization_name, <%= params %>);

View File

@ -40,6 +40,10 @@ class SqlTemplateRenderer
end end
def params_with_type def params_with_type
@function_signature['params'].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'].map do |p|
if not p['default'].nil? if not p['default'].nil?
"#{p['name']} #{p['type']} DEFAULT #{p['default']}" "#{p['name']} #{p['type']} DEFAULT #{p['default']}"
@ -49,7 +53,6 @@ class SqlTemplateRenderer
end end
return parameters.join(', ') return parameters.join(', ')
end end
end end