Sparql - delete queries stop working after update

淺唱寂寞╮ 提交于 2020-01-23 17:46:25

问题


I've created an application, which works with openrdf sesame and owlim module. Recently, I needed to update licence key to owlim (I received a key for the newest owlim version), so I was forced to update sesame as well.

Application was build with sesame 2.6.0 and owlim 4.3, now updated to sesame 2.6.8 and owlim 5.2

There are issues with delete sparql queries, which works in older version, so I got a hunch, that update is the problem.

Here is one such query:

PREFIX oporg: <http://sesame.company.org/OPropertiesOrg#>

WITH <users:>
DELETE {
?userID oporg:sessionID ?sessionID
}
INSERT {
?userID oporg:sessionID "qafnsi9p1172c0dprf9e4bhm23"
}
WHERE{
?userID oporg:name "admin"
}

this should (according what I remember :) delete every sessionID triplet with userID=admin and insert new sessionID triplet.

Insert part works, but delete part doesn't.


回答1:


The reason this no longer works is that your DELETE clause contains a variable (?sessionID) that is never bound to a value anywhere, so during the evaluation of the operation, this translates to an incomplete triple pattern and is ignored.

In earlier versions of Sesame, an unbound variable in the DELETE clause was interpreted to mean a wildcard. However, this is in conflict with the SPARQL specification, and was therefore fixed as a bug in Sesame release 2.6.7. See http://www.openrdf.org/issues/browse/SES-1047 for details.

You should modify your DELETE operation slightly, by adding the ?sessionID patern to your WHERE-clause, like so:

PREFIX oporg: <http://sesame.company.org/OPropertiesOrg#>

WITH <users:>
DELETE {
   ?userID oporg:sessionID ?sessionID
}
INSERT {
   ?userID oporg:sessionID "qafnsi9p1172c0dprf9e4bhm23"
}
WHERE{
   ?userID oporg:name "admin" ; 
           oporg:sessionID ?sessionID .
}


来源:https://stackoverflow.com/questions/11780014/sparql-delete-queries-stop-working-after-update

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!