Fixes a bug in SPARQL DESCRIBE implementation

Adds tests to ensure it won't happen again
pull/58/head
Tpt 4 years ago
parent 39fe1b1704
commit cd8032136a
  1. 18
      lib/src/sparql/eval.rs
  2. 1
      testsuite/oxigraph-tests/sparql/describe.rq
  3. 9
      testsuite/oxigraph-tests/sparql/describe_input.ttl
  4. 6
      testsuite/oxigraph-tests/sparql/describe_output.ttl
  5. 1
      testsuite/oxigraph-tests/sparql/describe_where.rq
  6. 16
      testsuite/oxigraph-tests/sparql/manifest.ttl

@ -2731,16 +2731,20 @@ impl<S: ReadableEncodedStore<Error = EvaluationError> + 'static> Iterator for De
Ok(tuple) => tuple,
Err(error) => return Some(Err(error)),
};
for subject in tuple.iter() {
if let Some(subject) = subject {
self.quads = Box::new(self.eval.dataset.encoded_quads_for_pattern(
let eval = self.eval.clone();
self.quads = Box::new(tuple.into_iter().flatten().flat_map(move |subject| {
eval.dataset
.encoded_quads_for_pattern(
Some(subject),
None,
None,
None,
));
}
}
Some(EncodedTerm::DefaultGraph),
)
.chain(
eval.dataset
.encoded_quads_for_pattern(Some(subject), None, None, None),
)
}));
}
}
}

@ -0,0 +1 @@
DESCRIBE <http://example.com/not_exist> <http://example.com/test>

@ -0,0 +1,9 @@
PREFIX schema: <http://schema.org/>
<http://example.com/test> a schema:Person ;
schema:name "test"@en ;
schema:parent <http://example.com/test2> ;
schema:child [ a schema:Person ] .
<http://example.com/test2> a schema:Person ;
schema:child <http://example.com/test> .

@ -0,0 +1,6 @@
PREFIX schema: <http://schema.org/>
<http://example.com/test> a schema:Person ;
schema:name "test"@en ;
schema:parent <http://example.com/test2> ;
schema:child [] .

@ -0,0 +1 @@
DESCRIBE ?s WHERE { ?s <http://schema.org/name> "test"@en }

@ -8,9 +8,25 @@
rdfs:label "Oxigraph SPARQL tests" ;
mf:entries
(
:describe
:describe_where
:group_concat_with_null
) .
:describe rdf:type mf:QueryEvaluationTest ;
mf:name "Simple DESCRIBE request" ;
mf:action
[ qt:query <describe.rq> ;
qt:data <describe_input.ttl> ] ;
mf:result <describe_output.ttl> .
:describe rdf:type mf:QueryEvaluationTest ;
mf:name "Simple DESCRIBE request" ;
mf:action
[ qt:query <describe.rq> ;
qt:data <describe_input.ttl> ] ;
mf:result <describe_output.ttl> .
:group_concat_with_null rdf:type mf:QueryEvaluationTest ;
mf:name "GROUP_CONCAT with NULL" ;
rdfs:comment "GROUP_CONCAT should ignore null values" ;

Loading…
Cancel
Save