From: Daniel Berger Date: 2002-08-31T00:36:10+09:00 Subject: dbi peculiar behavior Hi all, Ruby 1.6.7, dbi .16, oracle .2.11 I'm getting some odd behavior returning DBI::Row objects in iterative context. I *think* this is because of the way dbi is designed (to re-use the same reference), but I still think the behavior is wrong: require "dbi" class Test def initialize @dbh = DBI.connect(dsn,user,password) @sth = @dbh.prepare("select field1, field2 from some_table") @sth.execute end def myiter while r = @sth.fetch if block_given? yield r.dup else return r end end end end t = Test.new t.myiter{|row| row.push("X") puts row.join(', ') } if we assume our query returns 4 rows we get this: data, data, X data, data, X, X data, data, X, X, X data, data, X, X, X, X Is this expected behavior or a bug? I realize one solution is to just dup the row in "myiter", but I wanted to check. Regards, Dan