SERVICE SILENT should not remove tuple on failure

See: https://www.w3.org/TR/sparql11-federated-query/#serviceFailure
pull/21/head
Tpt 5 years ago
parent a1fcb6a9b7
commit 96837fb64d
  1. 20
      lib/src/sparql/eval.rs
  2. 3
      lib/tests/service_test_cases.rs

@ -128,11 +128,15 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
service_name,
graph_pattern,
..
} => match self.evaluate_service(service_name, graph_pattern, variables, from) {
Ok(result) => result,
} => match self.evaluate_service(service_name, graph_pattern, variables) {
Ok(result) => Box::new(result.flat_map(move |binding| {
binding
.map(|binding| combine_tuples(&binding, &from))
.transpose()
})),
Err(e) => {
if *silent {
Box::new(empty())
Box::new(once(Ok(from)))
} else {
Box::new(once(Err(e)))
}
@ -484,22 +488,14 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
service_name: &PatternValue,
graph_pattern: &'b GraphPattern,
variables: &'b [Variable],
from: EncodedTuple,
) -> Result<EncodedTuplesIterator<'b>> {
let service_name = self.dataset.decode_named_node(
get_pattern_value(service_name, &[])
.ok_or_else(|| format_err!("The SERVICE name is not bound"))?,
)?;
Ok(Box::new(
self.encode_bindings(
Ok(self.encode_bindings(
variables,
self.service_handler.handle(&service_name, &graph_pattern)?,
)
.flat_map(move |binding| {
binding
.map(|binding| combine_tuples(&binding, &from))
.transpose()
}),
))
}

@ -149,8 +149,7 @@ fn silent_service_empty_set_test() {
.into_values_iter()
.map(move |b| b.unwrap())
.collect::<Vec<_>>();
println!("Collected: {:?}", collected);
assert_eq!(collected.len(), 0);
assert_eq!(collected.len(), 1);
}
#[test]

Loading…
Cancel
Save