diff options
author | Munyoki Kilyungi | 2024-09-04 14:50:35 +0300 |
---|---|---|
committer | BonfaceKilz | 2024-09-05 16:39:14 +0300 |
commit | 8e28770342b65cff78441670f1841e0130dc9c4b (patch) | |
tree | a3428902ddce09cc956842d20fb56482ebbb1028 | |
parent | 348057ee134ce0cd918a3033c91f63fcd5d56497 (diff) | |
download | genenetwork3-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.py | 12 |
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 |