Feature request: let Query.execute return a hash

Bug #88921 reported by Benjamin Heitmann
2
Affects Status Importance Assigned to Milestone
ActiveRDF
New
Undecided
Unassigned

Bug Description

Currently Queries only return nested arrays with the results.

So if my query is:

results = Query.new.select(:p, :d).
      where(:p, RDF::type, SIOC::Post.class_uri).
      where(:p, DCTERMS::created, :d).
      where(:f, SIOC::container_of, :p).execute

Then if I want to iterate over the results I have to do it this way:

results.each do |r|
   # do something with r[0] and r[1]
end

If query.execute would return a hash using the symbols used for the query, then the whole thing
could be used in a much more readable way:

results = Query.new.select(:post, :date).
      where(:p, RDF::type, SIOC::Post.class_uri).
      where(:p, DCTERMS::created, :d).
      where(:f, SIOC::container_of, :p).execute

results.each do |r|
   # do something with r[:post] and r[:date]
end

This is especially usefull, when getting a lot of data from a single sparql query, in order to
optimize something for speed.

In order to not break backwards compatibility, this could be done only
if execute is called e.g. like this:

query.execute {:return => :hash }
or
query.execute( :hash )

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.