Makes SPARQL algebra private

pull/171/head
Tpt 4 years ago
parent 4b9b4a01b8
commit e4f97bafb3
  1. 26
      lib/src/sparql/algebra.rs
  2. 4
      lib/src/sparql/mod.rs
  3. 13
      server/src/main.rs

@ -214,9 +214,9 @@ impl<'a> TryFrom<&'a String> for Query {
#[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub struct Update {
/// The update base IRI
pub base_iri: Option<Iri<String>>,
pub(super) base_iri: Option<Iri<String>>,
/// The [update operations](https://www.w3.org/TR/sparql11-update/#formalModelGraphUpdate)
pub operations: Vec<GraphUpdateOperation>,
pub(super) operations: Vec<GraphUpdateOperation>,
}
impl Update {
@ -224,6 +224,28 @@ impl Update {
pub fn parse(update: &str, base_iri: Option<&str>) -> Result<Self, ParseError> {
parse_update(update, base_iri)
}
/// Returns [the query dataset specification](https://www.w3.org/TR/sparql11-query/#specifyingDataset) in [DELETE/INSERT operations](https://www.w3.org/TR/sparql11-update/#deleteInsert).
pub fn using_datasets(&self) -> impl Iterator<Item = &QueryDataset> {
self.operations.iter().filter_map(|operation| {
if let GraphUpdateOperation::DeleteInsert { using, .. } = operation {
Some(using)
} else {
None
}
})
}
/// Returns [the query dataset specification](https://www.w3.org/TR/sparql11-query/#specifyingDataset) in [DELETE/INSERT operations](https://www.w3.org/TR/sparql11-update/#deleteInsert).
pub fn using_datasets_mut(&mut self) -> impl Iterator<Item = &mut QueryDataset> {
self.operations.iter_mut().filter_map(|operation| {
if let GraphUpdateOperation::DeleteInsert { using, .. } = operation {
Some(using)
} else {
None
}
})
}
}
impl fmt::Display for Update {

@ -1,8 +1,8 @@
//! [SPARQL](https://www.w3.org/TR/sparql11-overview/) implementation.
//!
//! Stores execute SPARQL. See [`SledStore`](super::store::memory::SledStore::query()) for an example.
//! Stores execute SPARQL. See [`SledStore`](super::store::sled::SledStore::query()) for an example.
pub mod algebra;
mod algebra;
mod csv_results;
mod dataset;
mod error;

@ -22,7 +22,6 @@ use http_types::{
};
use oxigraph::io::{DatasetFormat, GraphFormat};
use oxigraph::model::{GraphName, GraphNameRef, NamedNode, NamedOrBlankNode};
use oxigraph::sparql::algebra::GraphUpdateOperation;
use oxigraph::sparql::{Query, QueryResults, QueryResultsFormat, Update};
use oxigraph::SledStore as Store;
use oxiri::Iri;
@ -494,16 +493,14 @@ fn evaluate_sparql_update(
.collect::<Result<Vec<NamedOrBlankNode>>>()
.map_err(bad_request)?;
if !default_graph_uris.is_empty() || !named_graph_uris.is_empty() {
for operation in &mut update.operations {
if let GraphUpdateOperation::DeleteInsert { using, .. } = operation {
if !using.is_default_dataset() {
bail_status!(400,
for using in update.using_datasets_mut() {
if !using.is_default_dataset() {
bail_status!(400,
"using-graph-uri and using-named-graph-uri must not be used with a SPARQL UPDATE containing USING",
);
}
using.set_default_graph(default_graph_uris.clone());
using.set_available_named_graphs(named_graph_uris.clone());
}
using.set_default_graph(default_graph_uris.clone());
using.set_available_named_graphs(named_graph_uris.clone());
}
}
store.update(update)?;

Loading…
Cancel
Save