sparql icon indicating copy to clipboard operation
sparql copied to clipboard

Issue deleting RDF list

Open u0078867 opened this issue 3 months ago • 3 comments

I have the following triples in a RDF::Repository:

_:g183184 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "1"^^<http://www.w3.org/2001/XMLSchema#integer> .
_:g183184 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:g183192 .
_:g183192 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "2"^^<http://www.w3.org/2001/XMLSchema#integer> .
_:g183192 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:g183200 .
_:g183200 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "3"^^<http://www.w3.org/2001/XMLSchema#integer> .
_:g183200 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
<http://example.org/my_list_1> <http://example.org/contains> _:g183184 .
_:g183208 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "4"^^<http://www.w3.org/2001/XMLSchema#integer> .
_:g183208 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:g183216 .
_:g183216 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "5"^^<http://www.w3.org/2001/XMLSchema#integer> .
_:g183216 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:g183224 .
_:g183224 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "6"^^<http://www.w3.org/2001/XMLSchema#integer> .
_:g183224 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
<http://example.org/my_list_2> <http://example.org/contains> _:g183208 .

I would like to delete the first list by using the following query in client.update(...):

PREFIX ex:  <http://example.org/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

DELETE {
  ?z rdf:first ?head ;
     rdf:rest ?tail .
} WHERE {
  ex:my_list_1 ex:contains ?list .
  ?list rdf:rest* ?z .
  ?z rdf:first ?head ;
     rdf:rest ?tail .
}

But it throws:

/home/davide/.rbenv/versions/3.4.2/lib/ruby/gems/3.4.0/gems/sparql-3.3.0/lib/sparql/algebra/operator/sequence.rb:51:in 'SPARQL::Algebra::Operator::Sequence#execute': undefined local variable or method 'block' for an instance of SPARQL::Algebra::Operator::Sequence (NameError)

        @solutions.each(&block) if block_given?
                         ^^^^^
	from /home/davide/.rbenv/versions/3.4.2/lib/ruby/gems/3.4.0/gems/rdf-3.3.3/lib/rdf/mixin/queryable.rb:131:in 'RDF::Queryable#query_execute'
	from /home/davide/.rbenv/versions/3.4.2/lib/ruby/gems/3.4.0/gems/sparql-3.3.0/lib/sparql/algebra/extensions.rb:328:in 'RDF::Queryable#query'
	from /home/davide/.rbenv/versions/3.4.2/lib/ruby/gems/3.4.0/gems/sparql-3.3.0/lib/sparql/algebra/operator/modify.rb:74:in 'SPARQL::Algebra::Operator::Modify#execute'
	from /home/davide/.rbenv/versions/3.4.2/lib/ruby/gems/3.4.0/gems/sparql-3.3.0/lib/sparql/algebra/operator/update.rb:71:in 'block in SPARQL::Algebra::Operator::Update#execute'
	from /home/davide/.rbenv/versions/3.4.2/lib/ruby/gems/3.4.0/gems/sparql-3.3.0/lib/sparql/algebra/operator/update.rb:70:in 'Array#each'
	from /home/davide/.rbenv/versions/3.4.2/lib/ruby/gems/3.4.0/gems/sparql-3.3.0/lib/sparql/algebra/operator/update.rb:70:in 'SPARQL::Algebra::Operator::Update#execute'
	from /home/davide/.rbenv/versions/3.4.2/lib/ruby/gems/3.4.0/gems/sparql-3.3.0/lib/sparql.rb:94:in 'SPARQL.execute'
	from /home/davide/.rbenv/versions/3.4.2/lib/ruby/gems/3.4.0/gems/sparql-client-3.3.0/lib/sparql/client.rb:359:in 'SPARQL::Client#update'

The complains seems to be at the asterisk in rdf:rest*.

sparql gem version is 3.3.0.

Any idea?

Thank you!

u0078867 avatar Sep 05 '25 14:09 u0078867

This should be fairly easy to track down with all the materials you provided. I won’t be able to get to this myself, but if you would care to take it on, that would be most appreciated.

gkellogg avatar Sep 05 '25 16:09 gkellogg

I wish I had the time, but sadly I don't ... :/ Thanks anyways!

u0078867 avatar Sep 05 '25 17:09 u0078867

Someone will get to it eventually. Cc/ @artob

gkellogg avatar Sep 05 '25 18:09 gkellogg