From: Jean-Denis Muys Date: 2009-02-06T19:03:46+09:00 Subject: Re: Bug in SQLite3 Ruby wrapper when results_as_hash=true? Quoting Ryan Davis : > > On Feb 5, 2009, at 08:06 , Jean-Denis Muys wrote: > > > > > The results is indeed a hash, but with spurious entries: > > > > [{"Name"=>"Doe", 0=>"Doe", 1=>"John", 2=>"555-123-4567", > > "Telephone"=>"555-123-4567", "Firstname"=>"John"}] > > looks like that is intentional. You can access a value by column name > or index (like an array). > > This may be, but it is not documented as such, and it breaks any attempt to iterate over the returned hash (without special treatment). Since I need to iterate over all values for all rows, I am now facing a choice: 1- Either I iterate using [an array of] hashes, testing each key as I go 2- Or I iterate in the default mode of [an array of] arrays, with no test, as each value is present once and only once. Without the test, option 1 was more attractive as the iterative treatment consists of outputting all records one line per column name, followed by one line per corresponding value. With the test, Option 2 becomes equally attractive, and (I suspect), more efficient. Comments welcome. Jean-Denis