about summary refs log tree commit diff
path: root/gn3/db/wiki.py
diff options
context:
space:
mode:
authorMunyoki Kilyungi2025-04-25 17:05:50 +0300
committerBonfaceKilz2025-04-25 18:57:37 +0300
commitcfb12c6277341126a0d177dc40f46f9e1126e81d (patch)
tree1d2a9278b927b9502dade7ca759ea182765b4552 /gn3/db/wiki.py
parentb6754b2ea3c94131639c762de5fe1facf41ef663 (diff)
downloadgenenetwork3-cfb12c6277341126a0d177dc40f46f9e1126e81d.tar.gz
Handle null species in wiki comment query
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn3/db/wiki.py')
-rw-r--r--gn3/db/wiki.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/gn3/db/wiki.py b/gn3/db/wiki.py
index f422589..e702569 100644
--- a/gn3/db/wiki.py
+++ b/gn3/db/wiki.py
@@ -22,12 +22,20 @@ def _decode_dict(result: dict):
 def get_latest_comment(connection, comment_id: int) -> int:
     """ Latest comment is one with the highest versionId """
     cursor = connection.cursor(DictCursor)
-    query = """ SELECT versionId AS version, symbol, PubMed_ID AS pubmed_ids, sp.Name AS species,
-        comment, email, weburl, initial, reason
-        FROM `GeneRIF` gr
-		INNER JOIN Species sp USING(SpeciesId)
-		WHERE gr.Id = %s
-		ORDER BY versionId DESC LIMIT 1;
+    query = """SELECT versionId AS version,
+       symbol,
+       PubMed_ID AS pubmed_ids,
+       COALESCE(sp.Name, 'no specific species') AS species,
+       comment,
+       email,
+       weburl,
+       initial,
+       reason
+FROM `GeneRIF` gr
+LEFT JOIN Species sp USING(SpeciesId)
+WHERE gr.Id = %s
+ORDER BY versionId DESC
+LIMIT 1;
     """
     cursor.execute(query, (str(comment_id),))
     result = _decode_dict(cursor.fetchone())