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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2007-Dec-06 10:00 UTC
Re: Leanest way to query with the results in a typed hash ?
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---