ruby-rdf / sparql

Ruby SPARQL library
http://rubygems.org/gems/sparql
The Unlicense
89 stars 14 forks source link

FILTER with !bound duplicates #8

Closed vhyza closed 11 years ago

vhyza commented 11 years ago

Hello,

with @jindrichmynarz we were trying to use following sparql query

PREFIX ex: <http://example.com/>

CONSTRUCT {
  [] ex:label "Should appear once" .
}
WHERE {
  OPTIONAL {
    ?s ?p ex:not-bound .
  }
  FILTER (!bound(?s))
}

on

@prefix ex: <http://example.com/> .

[] a ex:bound .
[] a ex:somethingElse .

and it returns two results

[ <http://example.com/label> "Should appear once"] .

[ <http://example.com/label> "Should appear once"] .

We think there should be some deduplication of results and should appear only once.

Here is gist for issue replication https://gist.github.com/vhyza/a00d415a70db429b8860

gkellogg commented 11 years ago

I actually just fixed a bug relates to this in RSF::Query, an empty GroupGraphPattern should just return one result, it was formerly returning a reault for every statement; that should address this issue; I'm probably not ready to release an updated gem yet, but I can update the rdf github repo later today.

gkellogg commented 11 years ago

Let me know if this solves your problem. I translated your gist into specs in spec/algebra/construct_spec.rb, which pass using the GitHub master version of the rdf gem. Note that there are some other minor failures that I am still looking into.

vhyza commented 11 years ago

Thanks a lot! Using git version of rdf gem solves our problem.