
|
If you were logged in you would be able to see more operations.
|
|
A query such as
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT * WHERE {
?foo rdfs:comment ?blah .
FILTER ("foo" + "blah" = ?blah)
}
will not be caught as invalid during parsing, but will result in an AssertionError during evaluation. The case where the values being operated on by '+' are constants could be caught during parsing, but if they were variables they could not, so some error during evaluation seems sensible. However, a QueryEvaluationException would seem better, ideally with some information about exactly what the problem is (rather than "value must not be null" as currently).
public void testQuery() throws Exception {
String notANumber = "not a number";
String queryString = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">" + "SELECT * {\n"
+ " ?foo rdfs:comment ?blah .\n" + " FILTER ( \"" + notANumber + "\" + \"bar\" = ?blah )\n" + "}";
Repository repo = new SailRepository(new MemoryStore());
repo.initialize();
RepositoryConnection connection = repo.getConnection();
try {
TupleQuery query = connection.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
try {
query.evaluate();
fail("Should fail");
} catch (QueryEvaluationException e) {
// Would hope for one of these, with detail of the problem
assertTrue("Should contain some details of the problem", e.getMessage().contains(
notANumber));
}
} finally {
connection.close();
}
}
|
|
This is 'just' an issue with the query optimizer. The query shouldn't fail, as suggested, but rather return zero results. SPARQL specifies that invalid operations such as these result in a type error, which cause the filter to fail. The query optimizer could optimize away the entire query to a simple 'false' in this case.
The bug in the constant optimizer has been fixed.
|
|