Skip to content

Commit 61fc2fe

Browse files
author
James Leigh
committed
Merge branch 'master' of github.com:eclipse/rdf4j into develop
2 parents e935f38 + fc8a382 commit 61fc2fe

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

core/queryparser/sparql/src/main/java/org/eclipse/rdf4j/query/parser/sparql/TupleExprBuilder.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.eclipse.rdf4j.model.Literal;
2222
import org.eclipse.rdf4j.model.Value;
2323
import org.eclipse.rdf4j.model.ValueFactory;
24+
import org.eclipse.rdf4j.model.datatypes.XMLDatatypeUtil;
2425
import org.eclipse.rdf4j.model.impl.BooleanLiteral;
2526
import org.eclipse.rdf4j.model.vocabulary.FN;
2627
import org.eclipse.rdf4j.model.vocabulary.RDF;
@@ -2765,7 +2766,8 @@ public ValueConstant visit(ASTRDFLiteral node, Object data)
27652766
// invalid URI
27662767
throw new VisitorException(e.getMessage());
27672768
}
2768-
literal = valueFactory.createLiteral(label, datatype);
2769+
String normalized = XMLDatatypeUtil.normalize(label, datatype);
2770+
literal = valueFactory.createLiteral(normalized, datatype);
27692771
}
27702772
else if (lang != null) {
27712773
literal = valueFactory.createLiteral(label, lang);
@@ -2781,7 +2783,9 @@ else if (lang != null) {
27812783
public ValueConstant visit(ASTNumericLiteral node, Object data)
27822784
throws VisitorException
27832785
{
2784-
Literal literal = valueFactory.createLiteral(node.getValue(), node.getDatatype());
2786+
IRI datatype = node.getDatatype();
2787+
String label = XMLDatatypeUtil.normalize(node.getValue(), datatype);
2788+
Literal literal = valueFactory.createLiteral(label, datatype);
27852789
return new ValueConstant(literal);
27862790
}
27872791

core/queryparser/sparql/src/test/java/org/eclipse/rdf4j/query/parser/sparql/SPARQLParserTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
import org.eclipse.rdf4j.query.algebra.StatementPattern;
3131
import org.eclipse.rdf4j.query.algebra.TupleExpr;
3232
import org.eclipse.rdf4j.query.algebra.UpdateExpr;
33+
import org.eclipse.rdf4j.query.algebra.ValueConstant;
34+
import org.eclipse.rdf4j.query.algebra.helpers.AbstractQueryModelVisitor;
3335
import org.eclipse.rdf4j.query.parser.ParsedBooleanQuery;
3436
import org.eclipse.rdf4j.query.parser.ParsedGraphQuery;
3537
import org.eclipse.rdf4j.query.parser.ParsedQuery;
@@ -310,4 +312,23 @@ public void testLongUnicode() throws Exception {
310312
assertEquals("\uD83D\uDE1F", lines[lines.length -1].replaceAll(".*\"(.*)\".*", "$1"));
311313
}
312314

315+
@Test
316+
public void testAdditiveExpression()
317+
throws Exception
318+
{
319+
String ask = "ASK { ?this <urn:test:score> ?score FILTER (!(?score+5 != 0)) }";
320+
321+
ParsedQuery q = parser.parseQuery(ask, null);
322+
q.getTupleExpr().visit(new AbstractQueryModelVisitor<Exception>() {
323+
324+
public void meet(ValueConstant node)
325+
throws Exception
326+
{
327+
String label = node.getValue().stringValue();
328+
assertFalse(label, label.startsWith("+"));
329+
}
330+
});
331+
332+
}
333+
313334
}

0 commit comments

Comments
 (0)