rdflib icon indicating copy to clipboard operation
rdflib copied to clipboard

Incorrect working when deleting triplets in a BerkeleyDB store

Open roelj opened this issue 1 year ago • 3 comments

Dear rdflib developers,

I'm running into a problem with the BerkeleyDB backend: It does not delete a triplet from an DELETE/INSERT query. I made a minimal reproducer here: https://gist.github.com/roelj/a7b2f1751d8fe23fab96404ec69a10c0

It comes down to this query:

PREFIX test: <http://test.nonexisting/>
PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd:  <http://www.w3.org/2001/XMLSchema#>

DELETE {
  GRAPH <test://default> {
    ?dataset test:title ?title .
    ?dataset test:modified_date ?modified_date .
  }
}
INSERT {
  GRAPH <test://default> {
    ?dataset test:title "Test"^^xsd:string .
    ?dataset test:modified_date "***variable***"^^xsd:dateTime .
  }
}
WHERE {
  GRAPH <test://default> {
    ?dataset rdf:type test:Dataset .
    ?dataset test:title ?title .
    ?dataset test:modified_date ?modified_date .
  }
}

Where this triplet gets duplicated (so, it isn't DELETEd, but the INSERT works):

?dataset test:modified_date ?modified_date .

This happens only with the BerkeleyDB backend. Using a Virtuoso endpoint works as expected (no duplicated triples). I hope it's clear.

roelj avatar Jan 29 '24 13:01 roelj

After experimenting a bit further, it seems that this only happens when using xsd:dateTime. When using xsd:string the issue is not present.

roelj avatar Jan 30 '24 09:01 roelj

Are you sure the DELETE command is matching the triple you want to remove? Try running it as a SELECT first to see if it's correctly targetted.

(I think you must target the literal type in the DELETE, i.e. add ^^xsd:dateTime)

nicholascar avatar Aug 01 '24 12:08 nicholascar

Thanks for your insights. Well, why would it not work being a variable? In fact, it works fine on external RDF stores (I tested Virtuoso, Fuseki and Blazegraph).

How would I write the query from my initial report to target the literal type?

roelj avatar Aug 01 '24 14:08 roelj