Skip to content

Store query and update methods queryGraph parameter does not support ConjunctiveGraph and Dataset #1396

@Tpt

Description

@Tpt

The query and update methods of the Store abstract class allows to overide rdflib default SPARQL evaluator.
They both provide a queryGraph parameter to provide the default graph identifier.
However this parameter is not helpful enough to allow a proper implementation of SPARQL evaluation if the Store is used inside of a ConjunctiveGraph (for update) or a Dataset (both query and update).

Problems:

  1. With query and Dataset.
    Dataset(store="MyCustomStore").update("INSERT DATA {}") will call the underlying MyCustomStore with the parameter queryGraph=BNode("abcde") with BNode("abcde") the dataset identifier instead of queryGraph=URI("urn:x-rdflib:default") that identifies the default graph and is used by the basic triple insertion and deletion method. With this parameter the Store query evaluator will query the _:abcde graph even if the triples are by default added in the default graph identified by <urn:x-rdflib:default>.

  2. With update and ConjunctiveGraph.
    ConjunctiveGraph(store="MyCustomStore").update("INSERT DATA {}") will call the underlying MyCustomStore with the parameter queryGraph="__UNION__". With only this information the underlying store does not know what is the identifier of the ConjunctiveDataset default graph in which the triples should be added if the update contains an INSERT or a LOAD action.

  3. With update and Dataset.
    Similarly to the query method the queryGraph parameter is set to the Dataset identifier and not URI("urn:x-rdflib:default") so the update is evaluated against the _:abcde graph even if triples are by default added to the default graph (<urn:x-rdflib:default>) by the add method.

A possible solution might be to:

  1. Set queryGraph to URI("urn:x-rdflib:default") for Dataset query and update.
  2. Add a new parameter updateGraph to the update method. It would keep the same value as queryGraph if the update is called from a Graph or a Dataset and to the ConjunctiveGraph identifier if the update is called from a ConjunctiveGraph.

Metadata

Metadata

Assignees

No one assigned

    Labels

    concept: RDF datasetRelates to the RDF datasets concept.coreRelates to core functionality of RDFLib, i.e. `rdflib.{graph,store,term}`id-as-cntxttracking related issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions