RDFLib/rdflib — pull request #395 by bcogrel (2014-05-19 18:42:25+00:00)
Title: SPARQL Update request expression should not depend on the store used by a basic named graph

With the default `IOMemory` store, SPARQL update requests given to a basic named graph should not explicit the graph URI by using the GRAPH keyword:
```python
>>> cg = ConjunctiveGraph()
>>> g = cg.get_context("urn:graph")
>>> g.update("INSERT DATA { }")
>>> set(g.triples((None, None, None))) == set([(URIRef("urn:bob"), URIRef("urn:likes"), URIRef("urn:pizza"))])
True
>>> g.update("INSERT DATA { GRAPH { } }")
Exception: You performed a query operation requiring a dataset (i.e. ConjunctiveGraph), but operating currently on a single graph.
```
For me, this behavior is good and I would expect it to be the same when I use a `SPARQLUpdateStore`. However, in such a case, the first request update the default graph of the conjunctive graph but not the named graph. The second request is not rejected and produces the expected update:
```python
>>> cg = ConjunctiveGraph(SPARQLUpdateStore(queryEndpoint="http://localhost:3030/test/query", update_endpoint="http://localhost:3030/test/update"))
>>> g = cg.get_context("urn:graph")
>>> g.update("INSERT DATA { }")
>>> set(g.triples((None, None, None))) == set([(URIRef("urn:bob"), URIRef("urn:likes"), URIRef("urn:pizza"))])
False
>>> g.update("INSERT DATA { GRAPH { } }")
>>> set(g.triples((None, None, None))) == set([(URIRef("urn:bob"), URIRef("urn:likes"), URIRef("urn:pizza"))])
True
```
I propose a basic patch to align `SPARQLUpdateStore` with the default store.

One question remains: should we send an Exception when GRAPH is included in the request or just warn?