-
Hi guys, i have this problem when i try call endpoint /rpc/login: { "message": "Could not find the public.login() function in the schema cache", but i created function login in public schema not in cache, please how to fix that? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 15 replies
-
Hi! The error mentions that the function cannot be found in the Schema Cache that PostgREST uses to get metadata from the database. What may be happening is that you had PostgREST running when you created the function, causing the cache to be stale. Try reloading it to see if it works. If it does not help, share the function definition to see how it was created. |
Beta Was this translation helpful? Give feedback.
-
thanks for helping not work, my function login is: CREATE OR REPLACE FUNCTION cache.login(email text, pass text)
RETURNS basic_auth.jwt_token
LANGUAGE plpgsql
SECURITY DEFINER
AS $function$
declare
_role name;
result basic_auth.jwt_token;
begin
-- check email and password
select basic_auth.user_role(email, pass) into _role;
if _role is null then
raise invalid_password using message = 'invalid user or password';
end if;
select sign(
row_to_json(r), 'reallyreallyreallyreallyreallyverysafe'
) as token
from (
select _role as role, login.email as email,
extract(epoch from now())::integer + 60*60 as exp
) r
into result;
return result;
end;
$function$
; function is created in my database: |
Beta Was this translation helpful? Give feedback.
-
i changed function restarted database and reloaded schema the error changed to: { |
Beta Was this translation helpful? Give feedback.
i changed function restarted database and reloaded schema the error changed to:
{
"message": "Could not find the public.login() function or the public.login function with a single unnamed json or jsonb parameter in the schema cache",
"hint": "If a new function was created in the database with this name and parameters, try reloading the schema cache."
}