- 
                Notifications
    You must be signed in to change notification settings 
- Fork 577
Open
Labels
Description
When using a graph with SPARQLStore, Graph.query will call Store.query:
Lines 1381 to 1391 in 0856ac8
| if hasattr(self.store, "query") and use_store_provided: | |
| try: | |
| return self.store.query( | |
| query_object, | |
| initNs, | |
| initBindings, | |
| self.default_union and "__UNION__" or self.identifier, | |
| **kwargs, | |
| ) | |
| except NotImplementedError: | |
| pass # store has no own implementation | 
And this will then proceed to assert that the query is a str:
rdflib/rdflib/plugins/stores/sparqlstore.py
Lines 183 to 192 in 0856ac8
| def query( | |
| self, | |
| query, | |
| initNs=None, # noqa: N803 | |
| initBindings=None, | |
| queryGraph=None, | |
| DEBUG=False, | |
| ): | |
| self.debug = DEBUG | |
| assert isinstance(query, str) | 
And even without this assert, things won't work unless it is a str.
This is not an ideal situation, a better situation would be one of:
- Either don't support query objects, and only strings
- Obtain a string for the query object in SPARQLStore
- Have a different methods for working with prepared query
Either way, the interface of Store ideally should have a good match with all the implementations of it that comes with RDFLib.