Forums | Admin

Discussion Forums: help

Start New Thread Start New Thread

 

By: Joel VanderWerf
ResultSet#to_a is not idempotent [ reply ]  
2008-06-14 16:33
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]]
[]