CREATE OR REPLACE FUNCTION public.defaultmapviewport(hasura_session json)
RETURNS viewport_info
STABLE
AS $function$
case hasura_session ->> 'x-hasura-default-country-code'
when 'FR' then select lat, lng from places where slug_en = 'city-paris'
when 'ES' then select lat, lng from places where slug_en = 'municipality-madrid'
end;
END $function$ language SQL;
I'm getting a syntax error near case, even though it seems right. What could be the problem?
Viewport info:
create table viewport_info(
lat float,
lng float
);