DEV Community

Bharathim31
Bharathim31

Posted on

How to write a json in middle of union functionality throwing error

I wrote a union function in the middle of union wrote a json object is one of the parameter, but throwing error : could not identify an equality operator for type json. Here is my code. select(SELECT array_to_json(array_agg(row_to_json(resdt))) FROM (select vt.task_id,vp.project_name,vp.status as project_status, vt.project_id,vt.task_description,vt.planned_start_date,vt.planned_end_date, (select array_to_json(array_agg(row_to_json(b))) FROM (select vl.* from public."VOfficeApp_task" vat inner join public."VOfficeApp_task_labels" vtl on vat.task_id = vtl.task_id inner join public."VOfficeApp_labels" vl on vl.label_id = vtl.label_id where vl.status = true and vat.task_id = vt.task_id )b)as label_name, (select array_to_json(array_agg(row_to_json(b))) FROM (select tr.task_resource_id,tr.task_id,tr.project_resource_id , tr.assigned_date,tr.assigned_by,pr.employee_id as id, concat(u.first_name,u.last_name) as employeename from public."VOfficeApp_task" vtr inner join public."VOfficeApp_project_resources" pr on pr.project_id = vtr.project_id inner join public."VOfficeApp_task_resource" tr on tr.project_resource_id = pr.project_resource_id and tr.task_id = vt.task_id inner join public."VOfficeApp_user" u on u.id =pr.employee_id where tr.released_date is null and vtr.task_id =vt.task_id and vtr.status != 'Delete')b)as user_name, (select count(task_id)from public."VOfficeApp_task" ptra where ptra.task_id = vt.task_id and status = 'Assigned')Active_count, from public."VOfficeApp_task" vt inner join public."VOfficeApp_projects" vp on vt.project_id = vp.project_id inner join public."VOfficeApp_task_resource" vtr on vt.task_id = vtr.task_id inner join public."VOfficeApp_project_resources" vpr on vtr.project_resource_id = vpr.project_resource_id left join public."VOfficeApp_conversation" cvv on cvv.projtaskid = vt.task_id where vp.company_id = companyid and vp.created_by = createdby and vt.status != 'Delete' --order by vt.task_id desc union select vt.task_id,vp.project_name,vp.status as project_status, vt.project_id,vt.task_description,vt.planned_start_date,vt.planned_end_date, (select array_to_json(array_agg(row_to_json(b))) FROM (select vl.* from public."VOfficeApp_task" vat inner join public."VOfficeApp_task_labels" vtl on vat.task_id = vtl.task_id inner join public."VOfficeApp_labels" vl on vl.label_id = vtl.label_id where vl.status = true and vat.task_id = vt.task_id )b)as label_name, (select array_to_json(array_agg(row_to_json(b))) FROM (select tr.task_resource_id,tr.task_id,tr.project_resource_id , tr.assigned_date,tr.assigned_by,pr.employee_id as id, concat(u.first_name,u.last_name) as employeename from public."VOfficeApp_task" vtr inner join public."VOfficeApp_project_resources" pr on pr.project_id = vtr.project_id inner join public."VOfficeApp_task_resource" tr on tr.project_resource_id = pr.project_resource_id and tr.task_id = vt.task_id inner join public."VOfficeApp_user" u on u.id =pr.employee_id where tr.released_date is null and vtr.task_id =vt.task_id and vtr.status != 'Delete')b)as user_name, from public."VOfficeApp_task" vt inner join public."VOfficeApp_projects" vp on vt.project_id = vp.project_id inner join public."VOfficeApp_task_resource" vtr on vt.task_id = vtr.task_id inner join public."VOfficeApp_project_resources" vpr on vtr.project_resource_id = vpr.project_resource_id --inner join public."VOfficeApp_user" u on u.id =vpr.employee_id where vp.company_id = companyid and vpr.employee_id = createdby and vt.status != 'Delete' --order by vt.task_id desc )resdt)as My_tasks;

Top comments (0)