Skip to content

Commit

Permalink
Update overpass_py return jsonb versus a string when there is no value
Browse files Browse the repository at this point in the history
  • Loading branch information
xbgmsharp committed Jan 22, 2024
1 parent c1b71ca commit f25e735
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions initdb/02_3_3_signalk_public_functions_py.sql
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,11 @@ AS $reverse_geoip_py$
#plpy.notice('IP [{}] [{}]'.format(_ip, r.status_code))
if r.status_code == 200:
#plpy.notice('Got [{}] [{}]'.format(r.text, r.status_code))
return r.json();
return r.json()
else:
plpy.error('Failed to get ip details')
return '{}'
$reverse_geoip_py$ LANGUAGE plpython3u;
return {}
$reverse_geoip_py$ IMMUTABLE strict TRANSFORM FOR TYPE jsonb LANGUAGE plpython3u;
-- Description
COMMENT ON FUNCTION
public.reverse_geoip_py_fn
Expand Down Expand Up @@ -479,10 +479,10 @@ AS $overpass_py$
if r_dict["elements"]:
if "tags" in r_dict["elements"][0] and r_dict["elements"][0]["tags"]:
return r_dict["elements"][0]["tags"]; # return the first element
return '{}'
return {}
else:
plpy.notice('overpass-api Failed to get overpass-api details')
return '{}'
return {}
$overpass_py$ IMMUTABLE strict TRANSFORM FOR TYPE jsonb LANGUAGE plpython3u;
-- Description
COMMENT ON FUNCTION
Expand Down

0 comments on commit f25e735

Please sign in to comment.