I'm trying to make a reservation function for a computed field in Hasura (PostgreSQL). The code I'm trying to make gets the game_length from the table rooms and returns a timestamp with the game_length + start_time. However, I am new to functions in SQL and I can't seem to get this function working, as I am getting an error that states: postgres-error: operator does not exist: bigint = text. Does anyone know what I am doing wrong?
The test table consists of: id (int), start_time (timestamp), game_length(int), and room_id(int)
CREATE OR REPLACE FUNCTION public.calculate_reservation_total_time(t test)
RETURNS timestamp with time zone
LANGUAGE sql
STABLE
AS $function$
SELECT t.start_time + (SELECT count(*) FROM rooms WHERE id=t.room_id ||' minutes')::interval;
$function$