SPARQL update with a binding variable for the graph URI seems not to work properly:
import rdflib
from rdflib.plugins.stores.memory import Memory
store = Memory()
graph = rdflib.Graph(identifier="urn:example:graph", store=store)
dataset = rdflib.Dataset(store=store)
dataset.add_graph(graph)
dataset.update("""
insert data {
graph ?g { <urn:example:subject> <urn:example:predicate> "another value" }
}
""", initBindings={
"g": graph.identifier
})
print([ctx.identifier for ctx in dataset.contexts()])
print(graph.serialize())
The list of context identifiers printed is:
[rdflib.term.Variable('g'), rdflib.term.URIRef('urn:example:graph'), rdflib.term.URIRef('urn:x-rdflib:default')]
So, instead of updated the graph "urn:example:graph", the sparql update has created a new graph with an identifier which is the variable g.
SPARQL update with a binding variable for the graph URI seems not to work properly:
The list of context identifiers printed is: [rdflib.term.Variable('g'), rdflib.term.URIRef('urn:example:graph'), rdflib.term.URIRef('urn:x-rdflib:default')]
So, instead of updated the graph "urn:example:graph", the sparql update has created a new graph with an identifier which is the variable g.