
| Key: |
SES-565
|
| Type: |
Bug
|
| Status: |
Open
|
| Priority: |
Major
|
| Assignee: |
Unassigned
|
| Reporter: |
Mike Gould
|
| Votes: |
0
|
| Watchers: |
1
|
|
If you were logged in you would be able to see more operations.
|
|
Sesame
Created: 12/Jun/08 12:34 PM
Updated: 04/Jul/08 10:21 AM
|
|
| Component/s: |
SeRQL
|
| Affects Version/s: |
2.1.2
|
| Fix Version/s: |
3.x
|
|
|
Environment:
|
Sesame 2.1.2 on Sun Java 6 64bit Linux
|
|
Hi,
Nested queries don't seem to work when the inner query references a variable from the outer query.
The query example in the manual at http://www.openrdf.org/doc/sesame2/2.1.2/users/ch09.html#section-exists should return one result but it doesn' return any as the JUnit test below demonstrates.
Also it would be useful to have some clarification of how the variable bindings work between inner and outer queries. Are the variables completely independent? Is the "where <inner-var> = <outer-var>" used in the example the preferred way of linking inner or outer variables or can variables bound in the outer query be simply referenced in the inner one.
JUnit example (imports org.apache.commons.io.IOUtils ):
public void testNestedSerqlExists() throws Exception {
String dataString =
"@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n" +
"@prefix ex: <http://example.org/things#> .\n" +
"\n" +
"_:a rdf:type ex:Person .\n" +
"_:a ex:name \"John\" .\n" +
"_:a ex:hobby \"Stamp collecting\" .\n" +
"\n" +
"_:b rdf:type ex:Person .\n" +
"_:b ex:name \"Ringo\" .\n" +
"_:b ex:hobby \"Crossword puzzles\" .\n" +
"\n" +
"_:c rdf:type ex:Author .\n" +
"_:c ex:name \"John\" .\n" +
"_:c ex:authorOf \"Let it be\".\n" +
"\n" +
"";
InputStream dataStream = IOUtils.toInputStream(dataString);
SailRepository repo = new SailRepository(new MemoryStore());
repo.initialize();
SailRepositoryConnection connection = repo.getConnection();
connection.setAutoCommit(false);
connection.add(dataStream, "", RDFFormat.N3);
connection.commit();
String queryString =
"SELECT name, hobby\n" +
"FROM {} rdf:type {ex:Person};\n" +
" ex:name {name};\n" +
" ex:hobby {hobby}\n" +
"WHERE EXISTS ( SELECT n\n" +
" FROM {} rdf:type {ex:Author};\n" +
" ex:name {n};\n" +
" ex:authorOf {}\n" +
" WHERE n = name\n" +
" )\n" +
"USING NAMESPACE\n" +
" ex = <http://example.org/things#>" +
"\n";
TupleQuery query = connection.prepareTupleQuery(QueryLanguage.SERQL, queryString);
TupleQueryResult result = query.evaluate();
assertTrue("Should get at least one result",result.hasNext());
result.next();
assertFalse("Shouldn't get more than one result", result.hasNext());
}
|
|
|
There are no comments yet on this issue.
|
| |
|
|