Feature request: let Query.execute return a hash
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.
where(:p, RDF::type, SIOC::Post.
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.
where(:p, RDF::type, SIOC::Post.
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 )