Adds new easy equality method to NamedNode

pull/35/head
Tpt 5 years ago
parent 42fafbe57f
commit febaad9bdb
  1. 12
      lib/src/model/named_node.rs
  2. 21
      lib/src/sparql/plan_builder.rs

@ -58,3 +58,15 @@ impl<'a> From<&'a NamedNode> for rio::NamedNode<'a> {
rio::NamedNode { iri: node.as_str() } rio::NamedNode { iri: node.as_str() }
} }
} }
impl PartialEq<str> for NamedNode {
fn eq(&self, other: &str) -> bool {
self.as_str() == other
}
}
impl PartialEq<NamedNode> for str {
fn eq(&self, other: &NamedNode) -> bool {
self == other.as_str()
}
}

@ -1,4 +1,3 @@
use crate::model::vocab::xsd;
use crate::sparql::algebra::*; use crate::sparql::algebra::*;
use crate::sparql::model::*; use crate::sparql::model::*;
use crate::sparql::plan::PlanPropertyPath; use crate::sparql::plan::PlanPropertyPath;
@ -571,7 +570,7 @@ impl<E: Encoder> PlanBuilder<E> {
}, },
), ),
Function::Custom(name) => { Function::Custom(name) => {
if *name == *xsd::BOOLEAN { if name == "http://www.w3.org/2001/XMLSchema#boolean" {
self.build_cast( self.build_cast(
parameters, parameters,
PlanExpression::BooleanCast, PlanExpression::BooleanCast,
@ -579,7 +578,7 @@ impl<E: Encoder> PlanBuilder<E> {
graph_name, graph_name,
"boolean", "boolean",
)? )?
} else if *name == *xsd::DOUBLE { } else if name == "http://www.w3.org/2001/XMLSchema#double" {
self.build_cast( self.build_cast(
parameters, parameters,
PlanExpression::DoubleCast, PlanExpression::DoubleCast,
@ -587,7 +586,7 @@ impl<E: Encoder> PlanBuilder<E> {
graph_name, graph_name,
"double", "double",
)? )?
} else if *name == *xsd::FLOAT { } else if name == "http://www.w3.org/2001/XMLSchema#float" {
self.build_cast( self.build_cast(
parameters, parameters,
PlanExpression::FloatCast, PlanExpression::FloatCast,
@ -595,7 +594,7 @@ impl<E: Encoder> PlanBuilder<E> {
graph_name, graph_name,
"float", "float",
)? )?
} else if *name == *xsd::DECIMAL { } else if name == "http://www.w3.org/2001/XMLSchema#decimal" {
self.build_cast( self.build_cast(
parameters, parameters,
PlanExpression::DecimalCast, PlanExpression::DecimalCast,
@ -603,7 +602,7 @@ impl<E: Encoder> PlanBuilder<E> {
graph_name, graph_name,
"decimal", "decimal",
)? )?
} else if *name == *xsd::INTEGER { } else if name == "http://www.w3.org/2001/XMLSchema#integer" {
self.build_cast( self.build_cast(
parameters, parameters,
PlanExpression::IntegerCast, PlanExpression::IntegerCast,
@ -611,7 +610,7 @@ impl<E: Encoder> PlanBuilder<E> {
graph_name, graph_name,
"integer", "integer",
)? )?
} else if *name == *xsd::DATE { } else if name == "http://www.w3.org/2001/XMLSchema#date" {
self.build_cast( self.build_cast(
parameters, parameters,
PlanExpression::DateCast, PlanExpression::DateCast,
@ -619,7 +618,7 @@ impl<E: Encoder> PlanBuilder<E> {
graph_name, graph_name,
"date", "date",
)? )?
} else if *name == *xsd::TIME { } else if name == "http://www.w3.org/2001/XMLSchema#time" {
self.build_cast( self.build_cast(
parameters, parameters,
PlanExpression::TimeCast, PlanExpression::TimeCast,
@ -627,7 +626,7 @@ impl<E: Encoder> PlanBuilder<E> {
graph_name, graph_name,
"time", "time",
)? )?
} else if *name == *xsd::DATE_TIME { } else if name == "http://www.w3.org/2001/XMLSchema#dateTime" {
self.build_cast( self.build_cast(
parameters, parameters,
PlanExpression::DateTimeCast, PlanExpression::DateTimeCast,
@ -635,7 +634,7 @@ impl<E: Encoder> PlanBuilder<E> {
graph_name, graph_name,
"dateTime", "dateTime",
)? )?
} else if *name == *xsd::DURATION { } else if name == "http://www.w3.org/2001/XMLSchema#duration" {
self.build_cast( self.build_cast(
parameters, parameters,
PlanExpression::DurationCast, PlanExpression::DurationCast,
@ -643,7 +642,7 @@ impl<E: Encoder> PlanBuilder<E> {
graph_name, graph_name,
"duration", "duration",
)? )?
} else if *name == *xsd::STRING { } else if name == "http://www.w3.org/2001/XMLSchema#string" {
self.build_cast( self.build_cast(
parameters, parameters,
PlanExpression::StringCast, PlanExpression::StringCast,

Loading…
Cancel
Save