SPARQL: makes sure that STR is working properly on small IRIs

Issue #645
pull/656/head
Tpt 11 months ago committed by Thomas Tanon
parent c1b57f460b
commit b0a01e65fa
  1. 8
      lib/src/sparql/eval.rs
  2. 6
      testsuite/oxigraph-tests/sparql/manifest.ttl
  3. 3
      testsuite/oxigraph-tests/sparql/small_iri_str.rq
  4. 6
      testsuite/oxigraph-tests/sparql/small_iri_str.srx

@ -2134,7 +2134,13 @@ fn to_bool(term: &EncodedTerm) -> Option<bool> {
fn to_string_id(dataset: &DatasetView, term: &EncodedTerm) -> Option<SmallStringOrId> {
match term {
EncodedTerm::NamedNode { iri_id } => Some((*iri_id).into()),
EncodedTerm::NamedNode { iri_id } => Some(
if let Ok(value) = SmallString::try_from(dataset.get_str(iri_id).ok()??.as_str()) {
value.into()
} else {
SmallStringOrId::Big(*iri_id)
},
),
EncodedTerm::DefaultGraph
| EncodedTerm::NumericalBlankNode { .. }
| EncodedTerm::SmallBlankNode { .. }

@ -32,6 +32,7 @@
:one_or_more_shared
:one_or_more_star
:in_empty_error
:small_iri_str
) .
:small_unicode_escape_with_multibytes_char rdf:type mf:NegativeSyntaxTest ;
@ -151,3 +152,8 @@
mf:name "IN should propagate errors on the left side, even on the empty input" ;
mf:action [ qt:query <in_empty_error.rq> ] ;
mf:result <in_empty_error.srx> .
:small_iri_str rdf:type mf:QueryEvaluationTest ;
mf:name "Small IRI strings should be properly equal to their value" ;
mf:action [ qt:query <small_iri_str.rq> ] ;
mf:result <small_iri_str.srx> .

@ -0,0 +1,3 @@
ASK {
FILTER(STR(<ex:a>) = "ex:a")
}

@ -0,0 +1,6 @@
<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head>
</head>
<boolean>true</boolean>
</sparql>
Loading…
Cancel
Save