From cd27775b406482b11f44575ab196501a30d9b075 Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Thu, 2 Mar 2023 12:23:49 +0100 Subject: default sort order in sparql backend --- bsfs/triple_store/sparql/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bsfs/triple_store') diff --git a/bsfs/triple_store/sparql/utils.py b/bsfs/triple_store/sparql/utils.py index deca4d8..51de893 100644 --- a/bsfs/triple_store/sparql/utils.py +++ b/bsfs/triple_store/sparql/utils.py @@ -127,11 +127,12 @@ class Query(): """Return an executable sparql query.""" select = ' '.join(f'({head} as ?{name})' for head, name in self.select) return f''' - SELECT {self.root_head} {select} + SELECT DISTINCT {self.root_head} {select} WHERE {{ {self.root_head} <{ns.rdf.type}>/<{ns.rdfs.subClassOf}>* <{self.root_type}> . {self.where} }} + ORDER BY str({self.root_head}) ''' def __call__(self, graph: rdflib.Graph) -> rdflib.query.Result: -- cgit v1.2.3