Skip to content
This repository was archived by the owner on Feb 24, 2024. It is now read-only.

Commit e3a130f

Browse files
committed
add setof record functions
1 parent 9f3568b commit e3a130f

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

docs/references/api/stored_procedures.rst

+33
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,39 @@ PostgREST will detect if the function is scalar or table-valued and will shape t
420420
421421
To manually choose a return format such as binary, plain text or XML, see the section :ref:`scalar_return_formats`.
422422

423+
.. _untyped_functions:
424+
425+
Untyped functions
426+
-----------------
427+
428+
Functions that return ``record`` or ``SETOF record`` are supported:
429+
430+
.. code-block:: postgres
431+
432+
create function projects_setof_record() returns setof record as $$
433+
select * from projects;
434+
$$ language sql;
435+
436+
.. tabs::
437+
438+
.. code-tab:: http
439+
440+
GET /rpc/projects_setof_record HTTP/1.1
441+
442+
.. code-tab:: bash Curl
443+
444+
curl "http://localhost:3000/rpc/projects_setof_record"
445+
446+
.. code-block:: json
447+
448+
[{"id":1,"name":"Windows 7","client_id":1},
449+
{"id":2,"name":"Windows 10","client_id":1},
450+
{"id":3,"name":"IOS","client_id":2}]
451+
452+
However note that they will fail when trying to use :ref:`v_filter` and :ref:`h_filter` on them.
453+
454+
So while they can be used for quick tests, it's recommended to always choose a strict return type for the function.
455+
423456
Overloaded functions
424457
--------------------
425458

postgrest.dict

+1
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ unicode
182182
unikernel
183183
unix
184184
updatable
185+
Untyped
185186
UPSERT
186187
Upsert
187188
upsert

0 commit comments

Comments
 (0)