DELETE/INSERT operation does not work as expected using tdbupdate in
jena-3.0.0.

Starting with an empty TDB, I run the following two updates. The first
works as expected, adding 6 triples. The second should remove those
triples and add 9 new ones. Instead, the graph now has 20 triples. I did
not analyze them closely to see where they might be coming from.

If I run the DELETE clause of the 2nd update separately, it removes the
expected triples, and then the INSERT by itself will add the expected
triples.

===== 1st DELETE/INSERT =====
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix ex: <http://example.org/ns/foo#>
DELETE {
?thing_old rdfs:isDefinedBy ?thing_doc ;
  rdf:type ?old_type;
  ex:term ?old_term;
  ex:gAlt ?old_alt .
?old_alt ?old_alt_p ?old_alt_o .
}
INSERT {
_:b1 a ex:Thing1 ;
 rdfs:isDefinedBy ?thing_doc;
 ex:term "ABCD";
 ex:gAlt [a ex:Thing2;ex:gSyn "Automatic Widget"];
.
}
WHERE {
VALUES (?thing_doc) {(<http://example.org/doc/20849DBD>)}
OPTIONAL {?thing_old rdfs:isDefinedBy ?thing_doc ;
  rdf:type ?old_type ;
  ex:term ?old_term .
OPTIONAL {?thing_old ex:gAlt ?old_alt.
  ?old_alt ?old_alt_p ?old_alt_o.}}
}

===== 2nd DELETE/INSERT =====
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix ex: <http://example.org/ns/foo#>
DELETE {
?thing_old rdfs:isDefinedBy ?thing_doc ;
  rdf:type ?old_type;
  ex:term ?old_term;
  ex:gAlt ?old_alt .
?old_alt ?old_alt_p ?old_alt_o .
}
INSERT {
_:b1 a ex:Thing1 ;
 rdfs:isDefinedBy ?thing_doc;
 ex:term "ABCD";
 ex:gAlt [a ex:Thing2;ex:gSyn "Automatic Widget"];
 ex:gAlt [a ex:Thing2;ex:gSyn "Automated Widget"];
.

}
WHERE {
VALUES (?thing_doc) {(<http://example.org/doc/20849DBD>)}
OPTIONAL {?thing_old rdfs:isDefinedBy ?thing_doc ;
  rdf:type ?old_type ;
  ex:term ?old_term .
OPTIONAL {?thing_old ex:gAlt ?old_alt.
  ?old_alt ?old_alt_p ?old_alt_o.}}
}


Reply via email to