Leanest way to query with the results in a typed hash?

I’m querying many thousands of rows in a table, and would like the
result to be a hash with the values in the correct types eg. Time,
String, Fixnum.
I’d rather not use the normal find() as that creates model objects with
all their memory requirements. Is there a simple solution, or should I
put something together from the Rails source ?

Regards,

magpie

On 6 Dec 2007, at 03:19, Mr Magpie wrote:

I’m querying many thousands of rows in a table, and would like the
result to be a hash with the values in the correct types eg. Time,
String, Fixnum.
I’d rather not use the normal find() as that creates model objects
with
all their memory requirements. Is there a simple solution, or should I
put something together from the Rails source ?

ActiveRecord::Base.connection.select_all ‘select * from foos’
Will give you an array of hashes, but the values will all be strings

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs