find_workgroup_by_id return members
fix find_workgroup_members if no members
This commit is contained in:
@@ -8,10 +8,10 @@ begin
|
||||
select
|
||||
w.*,
|
||||
find_citizen_by_id(w.created_by_id) as created_by,
|
||||
find_citizen_by_id(w.owner_id) as owner
|
||||
find_citizen_by_id(w.owner_id) as owner,
|
||||
find_workgroup_members(w.id) as members
|
||||
into resource
|
||||
from workgroup as w
|
||||
left join citizen_in_workgroup ciw on w.id = ciw.workgroup_id
|
||||
where w.id = _id
|
||||
and deleted_at is null
|
||||
) as t;
|
||||
|
||||
@@ -7,10 +7,11 @@ begin
|
||||
z.*,
|
||||
find_user_by_id(z.user_id) as "user"
|
||||
from citizen_in_workgroup as ciw
|
||||
join workgroup as w on ciw.workgroup_id = w.id
|
||||
join citizen z on z.id = ciw.citizen_id
|
||||
where ciw.workgroup_id = _id
|
||||
where ciw.workgroup_id = _id and (w.deleted_at is null or w.deleted_at > now())
|
||||
) as t;
|
||||
|
||||
resource = coalesce(resource, '[]'::json);
|
||||
end;
|
||||
$$;
|
||||
|
||||
|
||||
|
||||
@@ -82,6 +82,9 @@ begin
|
||||
'Members must contain citizen1';
|
||||
assert not members::jsonb @> jsonb_build_array(jsonb_build_object('id', _citizen_id2)),
|
||||
'Members must NOT contain citizen2';
|
||||
-- Check if find_workgroup_by_id return members
|
||||
select find_workgroup_by_id((created_workgroup->>'id')::uuid) into selected_workgroup;
|
||||
assert json_array_length(selected_workgroup->'members') = 1, 'Workgroup must have members';
|
||||
|
||||
rollback;
|
||||
raise notice 'workgroup test pass';
|
||||
|
||||
Reference in New Issue
Block a user