Coalesce get organization members results (#1397)

Signed-off-by: Sergio Castaño Arteaga <tegioz@icloud.com>
This commit is contained in:
Sergio C. Arteaga 2021-06-15 14:36:06 +02:00 committed by GitHub
parent 4d80f53d00
commit de48fe5c4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -20,12 +20,12 @@ begin
where o.name = p_org_name
)
select
json_agg(json_strip_nulls(json_build_object(
coalesce(json_agg(json_strip_nulls(json_build_object(
'alias', alias,
'first_name', first_name,
'last_name', last_name,
'confirmed', confirmed
))),
))), '[]'),
(select count(*) from organization_members)
from (
select *

View File

@ -1,6 +1,6 @@
-- Start transaction and plan tests
begin;
select plan(3);
select plan(4);
-- Declare some variables
\set user1ID '00000000-0000-0000-0000-000000000001'
@ -67,6 +67,16 @@ select results_eq(
$$,
'Limit and offset of 1 used, member user2 returned'
);
select results_eq(
$$
select data::jsonb, total_count::integer
from get_organization_members('00000000-0000-0000-0000-000000000001', 'org1', 0, 2)
$$,
$$
values ('[]'::jsonb, 2)
$$,
'No members expected when using an offset of 2'
);
select throws_ok(
$$ select * from get_organization_members('00000000-0000-0000-0000-000000000001', 'org2', 0, 0) $$,
42501,