Skip to content

CLEAR DEFAULT statement erases named graphs #1275

@anatoly-scherbakov

Description

@anatoly-scherbakov
import rdflib


def test_clear_default():
    """Test @base directive with no slash after colon."""
    graph = rdflib.ConjunctiveGraph()

    graph.add((
        rdflib.SDO.title,
        rdflib.RDFS.subPropertyOf,
        rdflib.RDFS.label,
        rdflib.URIRef('https://example.org'),
    ))

    assert list(graph)

    graph.update('CLEAR DEFAULT')

    assert list(graph)   # Here is where the test fails

In this test, we create a ConjunctiveGraph with a NAMED graph in it. Then, we call CLEAR DEFAULT on the graph. Based on the definition of this statement,

Here, the DEFAULT keyword is used to remove all triples in the default graph of the Graph Store, the NAMED keyword is used to remove all triples in all named graphs of the Graph Store and the ALL keyword is used to remove all triples in all graphs of the Graph Store. The GRAPH keyword is used to remove all triples from a graph denoted by IRIref. This operation is not required to remove the empty graphs from the Graph Store, but an implementation may decide to do so.

As far as I could understand, DEFAULT graph is the default unnamed graph, so the triple we stored in the named graph before should not have been removed, but it apparently is.

Is perhaps this note in the same document relevant?

For services which form the default graph from the union of other graphs, CLEAR DEFAULT may have further implications which we leave unspecified here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions