about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--gn3/db/rdf/wiki.py2
-rw-r--r--gn3/db/wiki.py14
2 files changed, 13 insertions, 3 deletions
diff --git a/gn3/db/rdf/wiki.py b/gn3/db/rdf/wiki.py
index 4464eed..b2b301a 100644
--- a/gn3/db/rdf/wiki.py
+++ b/gn3/db/rdf/wiki.py
@@ -86,7 +86,7 @@ CONSTRUCT {
              rdf:type gnc:GNWikiEntry ;
              dct:identifier ?id_ ;
              dct:created ?createTime .
-    FILTER ( LCASE(?symbol) = LCASE('$symbol') ) .
+    FILTER ( LCASE(STR(?symbol)) = LCASE("$symbol") ) .
     {
         SELECT (MAX(?vers) AS ?max) ?id_ WHERE {
             ?comment dct:identifier ?id_ ;
diff --git a/gn3/db/wiki.py b/gn3/db/wiki.py
index c3c68e0..4721a69 100644
--- a/gn3/db/wiki.py
+++ b/gn3/db/wiki.py
@@ -9,6 +9,16 @@ class MissingDBDataException(Exception):
     """Error due to DB missing some data"""
 
 
+def _decode_dict(result: dict):
+    new_result = {}
+    for k, v in result.items():
+        if isinstance(v, bytes):
+            new_result[k] = v.decode()
+        else:
+            new_result[k] = v
+    return new_result
+
+
 def get_latest_comment(connection, comment_id: int) -> int:
     """ Latest comment is one with the highest versionId """
     cursor = connection.cursor(DictCursor)
@@ -20,7 +30,7 @@ def get_latest_comment(connection, comment_id: int) -> int:
 		ORDER BY versionId DESC LIMIT 1;
     """
     cursor.execute(query, (str(comment_id),))
-    result = cursor.fetchone()
+    result = _decode_dict(cursor.fetchone())
     if (pubmed_ids := result.get("pubmed_ids")) is None:
         pubmed_ids = ""
     result["pubmed_ids"] = [x.strip() for x in pubmed_ids.split()]
@@ -31,7 +41,7 @@ def get_latest_comment(connection, comment_id: int) -> int:
     """
 
     cursor.execute(categories_query, (str(comment_id), result["version"]))
-    categories = cursor.fetchall()
+    categories = [_decode_dict(x) for x in cursor.fetchall()]
     result["categories"] = [x["Name"] for x in categories]
     return result