[sqlite3] ResultSet#to_a is not idempotent

J

Joel VanderWerf

I asked this on the rubyforge sqlite list, but it's very quiet there, so
I'll risk asking it here...

Calling #to_a on a ResultSet seems to clear the result, so that the next
time #to_a returns an empty array. Is this intended?

$ cat test.rb
require 'sqlite3'

db = SQLite3::Database.new( "./test.sqlite" )
db.type_translation = true

db.execute <<END
create table if not exists t (
x real
)
END

db.execute "insert into t values (1)"

qry = db.prepare "select * from t"

res = qry.execute

p res.to_a
p res.to_a

$ ruby test.rb
[[1.0]]
[]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top