From f939e0166fec898fdae15bb1aae66218e65a8314 Mon Sep 17 00:00:00 2001 From: bruntib Date: Mon, 15 Apr 2024 01:12:10 +0200 Subject: [PATCH] [fix] Prevent overlapping report groups When getRunResults() API function queries the reports, the query uses LIMIT and OFFSET for returning the given page of the results due to their huge number. However, it is possible that different pages have overlapping reports. This way the resulting report list may contain duplicate reports. In this commit we apply an ordering on report id in order to prevent this. --- web/server/codechecker_server/api/report_server.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/web/server/codechecker_server/api/report_server.py b/web/server/codechecker_server/api/report_server.py index 73ec60033b..6085c23b3e 100644 --- a/web/server/codechecker_server/api/report_server.py +++ b/web/server/codechecker_server/api/report_server.py @@ -2089,6 +2089,13 @@ def getRunResults(self, run_ids, limit, offset, sort_types, sort_type_map, order_type_map) + # Most queries are using paging of reports due their great + # number. This is implemented by LIMIT and OFFSET in the SQL + # queries. However, if there is no ordering in the query, then + # the reports in different pages may overlap. This ordering + # prevents it. + q = q.order_by(Report.id) + if report_filter.annotations is not None: annotations = defaultdict(list) for annotation in report_filter.annotations: