-
Notifications
You must be signed in to change notification settings - Fork 1
Description
See https://gitter.im/m-ld/community?at=6149e78a8065e87a8ef6167a
Violation of principle of least surprise.
You can always delete any old property value using a variable, like this:
{ "@delete": { "@id": "<id>", "<property>": "?value" } }However there's a little subtlety to deletes with variables, which should probably be addressed with docs or maybe an improved semantic.
The subtlety is that the presence of a variable in the delete clause creates an implicit @where clause with the same content as the @delete, with the effective procedure:
- match graph triples against the (implicit)
@whereclause - capture values for the variable
?value - for each value found, substitute it into the
@deleteclause and delete those triples
So far this is the same behaviour as SPARQL DELETE WHERE.
The catch happens when you include a @insert clause as well, which you definitely want to do, if you are atomically updating a single-value property. Step 3 also applies to the insert; so if no value is matched, nothing gets inserted (even if the variable does not appear in the insert clause).
So, if you know there was definitely a value before (e.g. it's a mandatory property), you can just use a variable in the delete. But if you don't know that, then the only sane thing to do is to read the old value first, which is ungainly.
See also #31