Dear all,

We are having a little problem with left-empty optional queries, which I 
believe might be a little bug in how rdflib is dealing with query results with 
empty bindings. 

Consider an EMPTY graph and execute the following query

ASK { OPTIONAL {?x ?y ?z} }

It yields true, as other SPARQL engines. However, the query

SELECT * { OPTIONAL {?x ?y ?z} }

while yielding a SPARQLResult with one binding (len=1), its generator yields no 
ResultRow. Other engines return a single row, with all the projected variables 
set to None. 

Is this the correct behaviour? If not, I believe the problem is in file

rdflib/query.py

in the code

            if self._genbindings:
                for b in self._genbindings:
                    if b:  # don't add a result row in case of empty binding {}
                        self._bindings.append(b)
                        yield ResultRow(b, self.vars)
                self._genbindings = None
            else:
                for b in self._bindings:
                    if b:  # don't add a result row in case of empty binding {}
                        yield ResultRow(b, self.vars)

Both `if b:`are blocking the empty binding to appear in the result. 

Some more discussion on this topic can be found in: 

https://stackoverflow.com/questions/25131365/sparql-optional-query

at the end of the first answer.

best regards and thanks for the this great tool,
Sandro R. Fiorini

-- 
http://github.com/RDFLib
--- 
You received this message because you are subscribed to the Google Groups 
"rdflib-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rdflib-dev/80e9ef06-183f-4cde-97b5-74e4295141c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to