title: Why does Rails 3 with Mysql2 Gem ActiveRecord::Base.connection.execute(sql) return Array not Hash?
body: <p>I'm in the process of upgrading an application to Rails 3. I've decided to go with the mysql2 gem. There's some legacy code in the app that makes calls like:</p>
  
  <pre><code>results = ActiveRecord::Base.connection.execute(sql)
  </code></pre>
  
  <p>In the 2.3.x version, it used</p>
  
  <pre><code>results.each_hash do |row|
  ...
  </code></pre>
  
  <p>But with gem mysql2, results is type <code>Mysql2::Result</code>, which has only an <code>each</code> method. Checked the docs and they specify results should be a hash keyed on field name. Great!</p>
  
  <p>But in fact, it is an <code>Array</code>, not a <code>Hash</code>.</p>
  
  <p>When I use the rails console and instantiate my own <code>Mysql2::Client</code> and run the query there, the results <em>are</em> a <code>Hash</code>, which is what I want.</p>
  
  <p>In the rails application, I think it's better to use <code>ActiveRecord::Base.connection</code>, since it's been instantiated with options from database.yml. </p>
  
  <p>Note, unfortunately the result does not map to a model, so I can't use that.</p>
  
  <p>What I've done for now is, for example:</p>
  
  <pre><code>result = ActiveRecord::Base.connection.execute(sql)
  field_index = result.fields.index("field")
  result.each do |row|
    row[field_index]
  end
  </code></pre>
  
  <p>Which is ugly as sin.</p>
  
  <p>Does anyone how I can get it to return a Hash instead of Array?</p>