From c93c63ee8464a41cdea5640eb4d1f8a451b62550 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 19 May 2025 15:42:59 -0500 Subject: Handle case where the given publication_id does not exist. --- uploader/publications/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'uploader/publications/models.py') diff --git a/uploader/publications/models.py b/uploader/publications/models.py index 8dd62f3..2b0339b 100644 --- a/uploader/publications/models.py +++ b/uploader/publications/models.py @@ -82,7 +82,8 @@ def fetch_publication_by_id(conn: Connection, publication_id: int) -> dict: with conn.cursor(cursorclass=DictCursor) as cursor: cursor.execute("SELECT * FROM Publication WHERE Id=%s", (publication_id,)) - return dict(cursor.fetchone()) + _res = cursor.fetchone() + return dict(_res) if _res else {} def fetch_publication_phenotypes( -- cgit v1.2.3