diff options
| author | Munyoki Kilyungi | 2025-04-25 17:05:50 +0300 |
|---|---|---|
| committer | BonfaceKilz | 2025-04-25 18:57:37 +0300 |
| commit | cfb12c6277341126a0d177dc40f46f9e1126e81d (patch) | |
| tree | 1d2a9278b927b9502dade7ca759ea182765b4552 | |
| parent | b6754b2ea3c94131639c762de5fe1facf41ef663 (diff) | |
| download | genenetwork3-cfb12c6277341126a0d177dc40f46f9e1126e81d.tar.gz | |
Handle null species in wiki comment query
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
| -rw-r--r-- | gn3/db/wiki.py | 20 |
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()) |
