Im trying to create a function that accepts a list of uuids as a parameter.
My code:
create or replace function get_child_groups(input_parents_id uuid[])
returns table(id uuid, name text, parent_id uuid)
as
$$
WITH RECURSIVE c AS (
SELECT da.*
from device_group_v2 d
JOIN device_group_associations da on da.parent_id = d.id
where d.id in (input_parents_id)
UNION ALL
SELECT sa.*
FROM device_group_associations AS sa JOIN c ON c.child_id = sa.parent_id)
select * from(select d.* from c join device_group_v2 d on c.parent_id = d.id OR c.child_id = d.id) as x
union
select * from device_group_v2 where id in (input_parents_id)
$$ language sql;
This fails with:
[42883] ERROR: operator does not exist: uuid = uuid[] No operator matches the given name and argument types. You might need to add explicit type casts. Position: 290
What am I doing wrong? Is a kind of typecast required there?