[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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top