aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMunyoki Kilyungi2024-09-04 14:50:35 +0300
committerBonfaceKilz2024-09-05 16:39:14 +0300
commit8e28770342b65cff78441670f1841e0130dc9c4b (patch)
treea3428902ddce09cc956842d20fb56482ebbb1028
parent348057ee134ce0cd918a3033c91f63fcd5d56497 (diff)
downloadgenenetwork3-8e28770342b65cff78441670f1841e0130dc9c4b.tar.gz
Update comment explaining why CONSTRUCT doesn't respect ORDER BY.
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
-rw-r--r--gn3/db/rdf/wiki.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/gn3/db/rdf/wiki.py b/gn3/db/rdf/wiki.py
index f945f06..f7bec47 100644
--- a/gn3/db/rdf/wiki.py
+++ b/gn3/db/rdf/wiki.py
@@ -156,9 +156,13 @@ CONSTRUCT {
else:
result["pubmed_ids"] = []
result["version"] = int(result["version"])
- # We manually sort the array, since somehow "ORDER BY" in the
- # sparql query is jumbled up during framing and compacting. This
- # operation isn't heavy since we don't get many versions per wiki
- # entry.
+
+ # We manually sort the array, since the SPARQL engine does not
+ # provide a guarantee that it will support an ORDER BY clause in a
+ # CONSTRUCT. Using ORDER BY on a solution sequence for a CONSTRUCT
+ # or DESCRIBE query has no direct effect because only SELECT
+ # returns a sequence of results. See:
+ # <https://stackoverflow.com/questions/78186393>
+ # <https://www.w3.org/TR/rdf-sparql-query/#modOrderBy>
results["data"] = sorted(data, key=lambda d: d["version"], reverse=True)
return results