You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider the following function, that gets exposed as /rpc/login:
create or replace function public.login(options my_types.login_options) returns my_types.login_result as
In 7.0.1, this function would return a JSON array with a single element, and clients had to opt-in using 'Accept: application/vnd.pgrst.object+json'. Using nightly-2021-03-05-19-03-d3a8b5f, this function now returns a single object, that is, not a JSON array. I can't seem to opt-out of that. Although returning a single object makes more sense, unfortunately clients of the API already expect a single element JSON array, so an upgrade to the next PostgREST version would be a breaking change for clients.
Consider whether it may be helpful to enable/disable that functionality via the postgrest.conf file, or via some other method (perhaps on a per-function basis, e.g. it would be great to disable the new functionality for stable endpoints such as /v1/login, but use the new default for newly added endpoints).
Yes, that's on purpose. It will be listed as a breaking change for the next release. I don't think we'll provide a way to opt out of that.
If you don't want to change your clients for now, you can just mark your function's return type as returns setof my_types.login_result - but still only return one row. This will give you the same one-element-array - in both the current and the next release.
Environment
Description of issue
Consider the following function, that gets exposed as /rpc/login:
In 7.0.1, this function would return a JSON array with a single element, and clients had to opt-in using 'Accept: application/vnd.pgrst.object+json'. Using nightly-2021-03-05-19-03-d3a8b5f, this function now returns a single object, that is, not a JSON array. I can't seem to opt-out of that. Although returning a single object makes more sense, unfortunately clients of the API already expect a single element JSON array, so an upgrade to the next PostgREST version would be a breaking change for clients.
Consider whether it may be helpful to enable/disable that functionality via the postgrest.conf file, or via some other method (perhaps on a per-function basis, e.g. it would be great to disable the new functionality for stable endpoints such as /v1/login, but use the new default for newly added endpoints).
#1779
The text was updated successfully, but these errors were encountered: