Add default values for the parameters in the functions

This commit is contained in:
Mario de Frutos 2016-01-22 10:38:34 +01:00
parent bd8ec71855
commit 4bffdb5de1
2 changed files with 15 additions and 1 deletions

View File

@ -51,3 +51,10 @@
params:
- { name: ip_address, type: text}
- name: cdb_geocode_street_point
return_type: Geometry
params:
- { name: searchtext, type: text}
- { name: city, type: text, default: 'NULL'}
- { name: state_province, type: text, default: 'NULL'}
- { name: country, type: text, default: 'NULL'}

View File

@ -40,7 +40,14 @@ class SqlTemplateRenderer
end
def params_with_type
@function_signature['params'].map { |p| "#{p['name']} #{p['type']}"}.join(', ')
parameters = @function_signature['params'].map do |p|
if not p['default'].nil?
"#{p['name']} #{p['type']} DEFAULT #{p['default']}"
else
"#{p['name']} #{p['type']}"
end
end
return parameters.join(', ')
end
end