type "geometry" does not exist

Hey all,

I'm new to Supabase and to PostgreSQL so I'm checking out functionality and following tutorials. I was trying to follow the tutorial for the PostGIS Geo queries extensions (https://supabase.com/docs/guides/database/extensions/postgis) and I've followed the tutorial to the letter. As soon as I try to run the following:

create or replace function nearby_restaurants(lat float, long float)
returns table (id public.restaurants.id%TYPE, name public.restaurants.name%TYPE, lat float, long float, dist_meters float)
language sql
as $$
  select id, name, st_y(location::geometry) as lat, st_x(location::geometry) as long, st_distance(location, st_point(long, lat)::geography) as dist_meters
  from public.restaurants
  order by location <-> st_point(long, lat)::geography;
$$;


I get this error:

ERROR:  42704: type "geometry" does not exist
LINE 5:   select id, name, st_y(location::geometry) as lat, st_x(location::geometry) as long, st_distance(location, st_point(long, lat)::geography) as dist_meters


So far I've tried:
  • restarting the project,
  • setting the search path to include the schema,
  • referencing the full path with public.geometry and postgis.geometry,
  • checking that the extension is installed (it is),
  • I've spent like an hour trying to get help from the AI but we just keep running in circles...
    Help?
Was this page helpful?