Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CONSTRUCT query with empty result on persistent dataset raises an error #775

Closed
scossu opened this issue Oct 15, 2017 · 3 comments
Closed

Comments

@scossu
Copy link

scossu commented Oct 15, 2017

Issue: When performing a CONSTRUCT query on a triplestore-backed Dataset, an error is raised if the result set is empty.

Environment: Linux, Python 3.5.3, rdflib 4.2.2, Fuseki/TDB 3.4.0 back end

To reproduce:

>>> from rdflib.plugins.stores.sparqlstore import SPARQLUpdateStore
>>> from rdflib import Dataset, Graph
>>> 
>>> store = SPARQLUpdateStore(queryEndpoint='http://localhost:3030/my_dataset/query',
...         update_endpoint='http://localhost:3030/my_dataset/update',
...         autocommit=False)
>>> ds = Dataset(store, default_union=True)
>>> 
>>> # This is expected:
>>> qres = ds.query('SELECT * WHERE { <urn:res:a> ?p ?o . }')
>>> len(qres)
22
>>> # This is expected:
>>> qres = ds.query('CONSTRUCT WHERE { <urn:res:a> ?p ?o . }')
>>> len(qres)
22
>>> # This is expected:
>>> qres = ds.query('SELECT * WHERE { <urn:bogus:0> ?p ?o . }')
>>> len(qres)
0
>>> # This is NOT expected:
>>> qres = ds.query('CONSTRUCT WHERE { <urn:bogus:0> ?p ?o . }')
Traceback (most recent call last):
  File "/home/scossu/code/my_prj/virtualenv/lib/python3.5/site-packages/rdflib/plugins/sparql/results/xmlresults.py", line 64, in __init__
    raise
RuntimeError: No active exception to reraise

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/scossu/code/my_prj/virtualenv/lib/python3.5/site-packages/rdflib/graph.py", line 1079, in query
    **kwargs)
  File "/home/scossu/code/my_prj/virtualenv/lib/python3.5/site-packages/rdflib/plugins/stores/sparqlstore.py", line 616, in query
    return SPARQLStore.query(self, *args, **kwargs)
  File "/home/scossu/code/my_prj/virtualenv/lib/python3.5/site-packages/rdflib/plugins/stores/sparqlstore.py", line 320, in query
    return Result.parse(res)
  File "/home/scossu/code/my_prj/virtualenv/lib/python3.5/site-packages/rdflib/query.py", line 197, in parse
    return parser.parse(source, **kwargs)
  File "/home/scossu/code/my_prj/virtualenv/lib/python3.5/site-packages/rdflib/plugins/sparql/results/xmlresults.py", line 34, in parse
    return XMLResult(source)
  File "/home/scossu/code/my_prj/virtualenv/lib/python3.5/site-packages/rdflib/plugins/sparql/results/xmlresults.py", line 69, in __init__
    "No RDF Graph, result-bindings or boolean answer found!")
rdflib.query.ResultException: No RDF Graph, result-bindings or boolean answer found! 
@gromgull
Copy link
Member

gromgull commented Nov 3, 2017

This is maybe fixed in #744 ?

@scossu
Copy link
Author

scossu commented Nov 3, 2017

@gromgull I am working on the master branch of RDFlib. When this gets merged I will be happy to test against my code.

@ghost
Copy link

ghost commented Dec 23, 2021

Unable to reproduce, no longer an issue.

@ghost ghost closed this as completed Dec 23, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants