Commits

Marc-Antoine Parent committed f364900

change in the store.query protocol

  • Participants
  • Parent commits 05fc8d9

Comments (0)

Files changed (3)

File virtuoso/tests/test_rdflib3.py

     def test_03_construct(self):
         self.graph.add(test_statements[0])
         q = "CONSTRUCT { ?s ?p ?o } WHERE { GRAPH %s { ?s ?p ?o } }" % (self.graph.identifier.n3(),)
-        result = self.store.query(None, q)
+        result = self.store.query(q)
         assert isinstance(result, Graph) or isinstance(result, Result)
         assert test_statements[0] in result
         self.graph.remove(test_statements[0])

File virtuoso/vsparql.py

         for pfx, ns in initNs.items():
             preamble += u"PREFIX %s: <%s>\n" % (pfx, ns)
 
-        return self.graph.store.query(None, preamble + query)
+        return self.graph.store.query(preamble + query)
 
 class Result(rdflib.query.Result):
     def __init__(self, qResult):

File virtuoso/vstore.py

     def clone(self):
         return Virtuoso(self.__dsn)
 
-    def query(self, graph, q, initNs={}, initBindings={},
-                    DEBUG=False, cursor=None, commit=False, explicit_context=False):
+    def query(self, q, initNs={}, initBindings={}, queryGraph=None, **kwargs):
         """
         Run a SPARQL query on the connection. Returns a Graph in case of
         DESCRIBE or CONSTRUCT, a bool in case of Ask and a generator over
         the results otherwise.
         """
-        if graph is not None and not explicit_context:
-            # Better safe than sorry. Could use re.match('GRAPH|FROM') etc. but slower.
-            if getattr(graph, 'default_context', None) is not None:
-                graph = graph.default_context
-            gid = graph.identifier
-            if not isinstance(gid, BNode):
-                q = u'DEFINE input:default-graph-uri <%s> %s' % (gid, q)
-        return self._query(q, initNs, initBindings, DEBUG, cursor, commit)
+        if queryGraph is not None and queryGraph is not '__UNION__':
+            q = u'DEFINE input:default-graph-uri <%s> %s' % (queryGraph, q)
+        return self._query(q, initNs, initBindings, **kwargs)
 
     def _query(self, q, initNs={}, initBindings={},
                     DEBUG=False, cursor=None, commit=False):