diff --git a/api.rst b/api.rst index 398c37b96..32e5d1a44 100644 --- a/api.rst +++ b/api.rst @@ -786,35 +786,6 @@ You can call overloaded functions with different number of arguments. GET /rpc/rental_duration?customer_id=232&from_date=2018-07-01 HTTP/1.1 -Explicit Qualification ----------------------- - -As of ``v5.0``, PostgREST executes a ``SET SCHEMA `` on each request, since this overrides the `search_path `_, function bodies need qualified schema names for any database object that is not in your exposed schema. - -.. code-block:: plpgsql - - -- Assuming that: - -- exposed schema is "api" - -- ST_AsGeoJSON is in the "public" schema - -- streets is in the "api" schema - CREATE FUNCTION api.sample() RETURNS json AS $$ - SELECT public.ST_AsGeoJSON(geom)::json FROM streets LIMIT 1; - -- Notice streets doesn't need the schema prefix while ST_AsGeoJSON does - $$ LANGUAGE sql; - -To avoid having to qualify many database objects, you can add a ``search_path`` to the function: - -.. code-block:: plpgsql - - CREATE FUNCTION api.sample_distance() RETURNS float8 AS $$ - SELECT ST_MakePoint(1, 1) <-> ST_MakePoint(10, 10); - -- If the search_path is not specified, this would have to be: - -- SELECT public.ST_MakePoint(1, 1) operator(public.<->) public.ST_MakePoint(10, 10); - $$ LANGUAGE sql SET search_path = public, api; - - -- existing functions can be altered to add a search_path - ALTER FUNCTION api.make_point(float8, float8) SET search_path = public, api; - Accessing Request Headers, Cookies and JWT claims -------------------------------------------------