From ec2469c3993b6edafcbe3e3b7ac826b0614227c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Csord=C3=A1s?= Date: Tue, 1 Jun 2021 13:52:56 +0200 Subject: [PATCH] [server] Fix getting existing analysis info It is possible when multiple runs are stored simultaneously to the server with the same analysis command that multiple entries are stored into the database. In this case we will select the first one. Using `one_or_none` sqlalchemy function is not an option because it will raise an exception if multiple entries are exists in the database. --- .../codechecker_server/api/mass_store_run.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/web/server/codechecker_server/api/mass_store_run.py b/web/server/codechecker_server/api/mass_store_run.py index be88ad1701..8d75343e55 100644 --- a/web/server/codechecker_server/api/mass_store_run.py +++ b/web/server/codechecker_server/api/mass_store_run.py @@ -656,12 +656,18 @@ def __store_analysis_info( analyzer_command.encode("utf-8"), zlib.Z_BEST_COMPRESSION) - analysis_info = session \ + analysis_info_rows = session \ .query(AnalysisInfo) \ .filter(AnalysisInfo.analyzer_command == cmd) \ - .one_or_none() - - if not analysis_info: + .all() + + if analysis_info_rows: + # It is possible when multiple runs are stored + # simultaneously to the server with the same analysis + # command that multiple entries are stored into the + # database. In this case we will select the first one. + analysis_info = analysis_info_rows[0] + else: analysis_info = AnalysisInfo(analyzer_command=cmd) session.add(analysis_info)