subzerocloud / subzero-starter-kit

Starter Kit and tooling for authoring GraphQL/REST API backends with subZero

Home Page:https://subzero.cloud

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

missmatches in return types of response lib functions

oakgary opened this issue · comments

Trying to add the response lib to my environment I run into the following error:

│2020-08-18 09:17:06.958 UTC [71] ERROR:  return type mismatch in function declared to return void                                                     │
│2020-08-18 09:17:06.958 UTC [71] DETAIL:  Actual return type is text.                                                                                 │
│2020-08-18 09:17:06.958 UTC [71] CONTEXT:  SQL function "set_header"                                                                                  │
│2020-08-18 09:17:06.958 UTC [71] STATEMENT:  create or replace function response.set_header(name text, value text) returns void as $$                 │
│        select set_config(                                                                                                                            │
│            'response.headers',                                                                                                                       │
│            jsonb_insert(                                                                                                                             │
│                (case coalesce(current_setting('response.headers',true),'')                                                                           │
│                when '' then '[]'                                                                                                                     │
│                else current_setting('response.headers')                                                                                              │
│                end)::jsonb,                                                                                                                          │
│                '{0}'::text[],                                                                                                                        │
│                jsonb_build_object(name, value))::text,                                                                                               │
│            true                                                                                                                                      │
│        );                                                                                                                                            │
│    $$ stable language sql;                                                                                                                           │
│psql:/docker-entrypoint-initdb.d/libs/response/schema.sql:35: ERROR:  return type mismatch in function declared to return void                        │
│DETAIL:  Actual return type is text.                                                                                                                  │
│CONTEXT:  SQL function "set_header" 

I assume that is because the return type of the set_config function is actually text.
What do you think could be the cause for me running into this problem?

€: same problem with the set_cookie and delete_cookie function

as discussed with @ruslantalpa in slack it is probably the postgres version; note: we did not verify this
i am using 10.9, while the starter-kit uses 11.x which seems to have become less strict

changing the return type of the three mentioned functions to text fixes the errors