我正在尝试针对reportportal v5 的postgresql 数据库编写一个sql,并发现没有明确的方法可以将project_id [和扩展的project_name] 放到与test_item 相同的行上。
我最初写了这个查询
select
tir.result_id,
ti.start_time,
tir.end_time,
tir.duration,
ti.item_id as test_item_id,
cq.issue_name,
STRING_AGG(l.log_message, '\t') as log_message
from test_item_results tir
left join test_item ti
on tir.result_id = ti.item_id
left join issue i
on tir.result_id = i.issue_id
join (select "name", project_type, issue_type_id, issue_group_id, issue_name from project p
join issue_type_project itp
on p.id = itp.project_id
join issue_type it
on itp.issue_type_id = it.id
where project_type = 'INTERNAL') cq
on i.issue_type = cq.issue_type_id
left join log l
on tir.result_id = l.item_id
where tir.status = 'FAILED'
and type IN ('STEP')
and cq.issue_name <> 'To Investigate'
and cq.issue_name in ('Product Bug', 'Automation Bug', 'System Issue', 'No Defect')
and l.log_message is not NULL
group by tir.result_id, ti.start_time, tir.end_time, ti.item_id, tir.result_id, i.issue_id, cq.issue_name
order by ti.start_time desc
但是,固定故障类型:产品错误、自动化错误、系统问题和无缺陷可用于所有项目(个人或内部)。然后,此查询会导致相同的 test_item 并且其结果在所有项目中重复。
然后我查看了一个 db 图,注意到有这些空模板表:pattern_template_test_item
和pattern_template
. 我在弄清楚如何使用这些方面没有任何成功。我看到该project
表与 有关系,pattern_template
并且pattern_template
与pattern_template_test_item
有关系test_item
。
任何人都知道如何编写这个sql?我的最终目标是从查询中获得不重复的输出。另外,我不能在这里使用 distinct 因为我需要测试和结果所属的实际项目。