diff --git a/lib/src/sparql/eval.rs b/lib/src/sparql/eval.rs index 8c94853d..8a49643d 100644 --- a/lib/src/sparql/eval.rs +++ b/lib/src/sparql/eval.rs @@ -2134,7 +2134,13 @@ fn to_bool(term: &EncodedTerm) -> Option { fn to_string_id(dataset: &DatasetView, term: &EncodedTerm) -> Option { 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 { .. } diff --git a/testsuite/oxigraph-tests/sparql/manifest.ttl b/testsuite/oxigraph-tests/sparql/manifest.ttl index 6594fe12..60a6a68d 100644 --- a/testsuite/oxigraph-tests/sparql/manifest.ttl +++ b/testsuite/oxigraph-tests/sparql/manifest.ttl @@ -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 ] ; mf:result . + +:small_iri_str rdf:type mf:QueryEvaluationTest ; + mf:name "Small IRI strings should be properly equal to their value" ; + mf:action [ qt:query ] ; + mf:result . diff --git a/testsuite/oxigraph-tests/sparql/small_iri_str.rq b/testsuite/oxigraph-tests/sparql/small_iri_str.rq new file mode 100644 index 00000000..6ecbcf18 --- /dev/null +++ b/testsuite/oxigraph-tests/sparql/small_iri_str.rq @@ -0,0 +1,3 @@ +ASK { + FILTER(STR() = "ex:a") +} \ No newline at end of file diff --git a/testsuite/oxigraph-tests/sparql/small_iri_str.srx b/testsuite/oxigraph-tests/sparql/small_iri_str.srx new file mode 100644 index 00000000..6e002ae6 --- /dev/null +++ b/testsuite/oxigraph-tests/sparql/small_iri_str.srx @@ -0,0 +1,6 @@ + + + + + true + \ No newline at end of file