create or replace function getTasksWithTags(input_owner_id uuid) returns table(id int8, title text, description text, priority text, due_by timestamptz, is_completed bool, tag_ids int8, tag_titles text) as $$
begin
return query select tasks.id, tasks.title, tasks.description, tasks.priority, tasks.due_by, tasks.is_completed, tags_to_tasks.tag_id, tags.title from tasks
left join tags_to_tasks on tasks.id = tags_to_tasks.task_id
left join tags on tags_to_tasks.tag_id = tags.id
where tasks.owner_id = input_owner_id;
end;
$$ language plpgsql;
create or replace function getTasksWithTags(input_owner_id uuid) returns table(id int8, title text, description text, priority text, due_by timestamptz, is_completed bool, tag_ids int8, tag_titles text) as $$
begin
return query select tasks.id, tasks.title, tasks.description, tasks.priority, tasks.due_by, tasks.is_completed, tags_to_tasks.tag_id, tags.title from tasks
left join tags_to_tasks on tasks.id = tags_to_tasks.task_id
left join tags on tags_to_tasks.tag_id = tags.id
where tasks.owner_id = input_owner_id;
end;
$$ language plpgsql;