# ResultSet#to\_a is not idempotent

**URL:** <https://www.ruby-forum.com/t/resultset-to-a-is-not-idempotent/140478>\
**Category:** Ruby\
**Created:** [June 14, 2008, 7:22pm UTC](https://www.ruby-forum.com/t/resultset-to-a-is-not-idempotent/140478 "2008-06-14T19:22:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joel\_VanderWerf](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@Joel\_VanderWerf](https://www.ruby-forum.com/u/Joel_VanderWerf)\
**Post date:** [June 14, 2008, 7:22pm UTC](https://www.ruby-forum.com/t/resultset-to-a-is-not-idempotent/140478/1 "2008-06-14T19:22:00Z")

</div>

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]]  
[]
