From 8e28770342b65cff78441670f1841e0130dc9c4b Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Wed, 4 Sep 2024 14:50:35 +0300 Subject: Update comment explaining why CONSTRUCT doesn't respect ORDER BY. Signed-off-by: Munyoki Kilyungi --- gn3/db/rdf/wiki.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'gn3/db/rdf') 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: + # + # results["data"] = sorted(data, key=lambda d: d["version"], reverse=True) return results -- cgit v1.2.3