change parent_id in comment
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
create or replace function comment(reference regclass, target_id uuid, created_by_id uuid, content text, parent_id uuid default null, out id uuid)
|
||||
create or replace function comment(reference regclass, target_id uuid, created_by_id uuid, content text, parent_comment_id uuid default null, out id uuid)
|
||||
language plpgsql as
|
||||
$$
|
||||
declare
|
||||
_created_by_id alias for created_by_id;
|
||||
_target_id alias for target_id;
|
||||
_content alias for content;
|
||||
_parent_id alias for parent_id;
|
||||
_parent_comment_id alias for parent_comment_id;
|
||||
_id alias for id;
|
||||
begin
|
||||
if reference = 'article'::regclass then
|
||||
insert into comment_on_article (created_by_id, target_id, content, parent_id)
|
||||
values (_created_by_id, _target_id, _content, _parent_id)
|
||||
insert into comment_on_article (created_by_id, target_id, content, parent_comment_id)
|
||||
values (_created_by_id, _target_id, _content, _parent_comment_id)
|
||||
returning comment_on_article.id into _id;
|
||||
elseif reference = 'constitution'::regclass then
|
||||
insert into comment_on_constitution (created_by_id, target_id, content, parent_id)
|
||||
values (_created_by_id, _target_id, _content, _parent_id)
|
||||
insert into comment_on_constitution (created_by_id, target_id, content, parent_comment_id)
|
||||
values (_created_by_id, _target_id, _content, _parent_comment_id)
|
||||
returning comment_on_constitution.id into _id;
|
||||
else
|
||||
raise exception 'comment with target as "%", is no implemented', reference::text;
|
||||
|
||||
@@ -15,7 +15,7 @@ begin
|
||||
find_reference_by_id(com.target_id, com.target_reference) as target,
|
||||
find_citizen_by_id(com.created_by_id) as created_by
|
||||
from "comment" as com
|
||||
where com.parents_ids @> array[_parent_id]
|
||||
where parent_id = _parent_id
|
||||
order by com.parents_ids nulls first, created_at desc,
|
||||
com.created_at desc
|
||||
limit "limit" offset "offset"
|
||||
|
||||
Reference in New Issue
Block a user