Allows comparing rdf:langString literals with the same language tag

pull/171/head
Tpt 3 years ago
parent 97bb227042
commit 45f612b6e3
  1. 57
      lib/src/sparql/eval.rs
  2. 4
      testsuite/oxigraph-tests/sparql/cmp_langString.rq
  3. 29
      testsuite/oxigraph-tests/sparql/cmp_langString.srx
  4. 6
      testsuite/oxigraph-tests/sparql/manifest.ttl

@ -2559,6 +2559,63 @@ fn partial_cmp_literals(
EncodedTerm::BigStringLiteral { value_id: b } => compare_str_ids(dataset, a, b),
_ => None,
},
EncodedTerm::SmallSmallLangStringLiteral {
value: a,
language: la,
} => match b {
EncodedTerm::SmallSmallLangStringLiteral {
value: b,
language: lb,
} if la == lb => a.partial_cmp(b),
EncodedTerm::BigSmallLangStringLiteral {
value_id: b,
language: lb,
} if la == lb => compare_str_str_id(dataset, a, b),
_ => None,
},
EncodedTerm::SmallBigLangStringLiteral {
value: a,
language_id: la,
} => match b {
EncodedTerm::SmallBigLangStringLiteral {
value: b,
language_id: lb,
} if la == lb => a.partial_cmp(b),
EncodedTerm::BigBigLangStringLiteral {
value_id: b,
language_id: lb,
} if la == lb => compare_str_str_id(dataset, a, b),
_ => None,
},
EncodedTerm::BigSmallLangStringLiteral {
value_id: a,
language: la,
} => match b {
EncodedTerm::SmallSmallLangStringLiteral {
value: b,
language: lb,
} if la == lb => compare_str_id_str(dataset, a, b),
EncodedTerm::BigSmallLangStringLiteral {
value_id: b,
language: lb,
} if la == lb => compare_str_ids(dataset, a, b),
_ => None,
},
EncodedTerm::BigBigLangStringLiteral {
value_id: a,
language_id: la,
} => match b {
EncodedTerm::SmallBigLangStringLiteral {
value: b,
language_id: lb,
} if la == lb => compare_str_id_str(dataset, a, b),
EncodedTerm::BigBigLangStringLiteral {
value_id: b,
language_id: lb,
} if la == lb => compare_str_ids(dataset, a, b),
_ => None,
},
EncodedTerm::FloatLiteral(a) => match b {
EncodedTerm::FloatLiteral(b) => a.partial_cmp(b),
EncodedTerm::DoubleLiteral(b) => Double::from(*a).partial_cmp(b),

@ -0,0 +1,4 @@
SELECT ?a ?b ?o WHERE {
VALUES (?a ?b) { ("a"@fr "b"@fr) ("a"@en "b"@fr) }
BIND(?a < ?b AS ?o)
}

@ -0,0 +1,29 @@
<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head>
<variable name="a"/>
<variable name="b"/>
<variable name="o"/>
</head>
<results>
<result>
<binding name="a">
<literal xml:lang="fr">a</literal>
</binding>
<binding name="b">
<literal xml:lang="fr">b</literal>
</binding>
<binding name="o">
<literal datatype="http://www.w3.org/2001/XMLSchema#boolean">true</literal>
</binding>
</result>
<result>
<binding name="a">
<literal xml:lang="en">a</literal>
</binding>
<binding name="b">
<literal xml:lang="fr">b</literal>
</binding>
</result>
</results>
</sparql>

@ -16,6 +16,7 @@
:values_in_filter_exists
:values_in_filter_not_exists
:subquery_in_filter_not_exists
:cmp_langString
) .
:describe rdf:type mf:QueryEvaluationTest ;
@ -65,3 +66,8 @@
mf:name "VALUES inside of FILTER EXISTS" ;
mf:action [ qt:query <subquery_in_filter_not_exists.rq> ] ;
mf:result <values_in_filter_exists.srx> .
:cmp_langString rdf:type mf:QueryEvaluationTest ;
mf:name "rdf:langString with the same language are comparable" ;
mf:action [ qt:query <cmp_langString.rq> ] ;
mf:result <cmp_langString.srx> .

Loading…
Cancel
Save