feature #4: add "article in title" on contitution creation

This commit is contained in:
2019-07-28 22:42:49 +02:00
parent a15847ab9e
commit ef740734b2
5 changed files with 108 additions and 12 deletions

View File

@@ -0,0 +1,24 @@
create or replace function find_constitution_title_by_id(in id uuid, out resource json) language plpgsql as
$$
declare
_id alias for id;
begin
select to_json(t)
from (
select
ti.id,
ti.name,
ti.rank,
array_agg(a order by ait.rank) as articles
into resource
from title as ti
left join article_in_title ait on ti.id = ait.title_id
left join article a on ait.article_id = a.id
where ti.id = _id
group by ti.id
order by ti.rank
) as t;
end;
$$;
-- drop function if exists find_constitution_title_by_id(uuid, out json);