title: connection.select_value only returns strings in postgres with pg gem
body: <p>I'm converting a rails app from using mysql (mysql2 gem) to postgres (pg gem).</p>
  
  <p>With mysql, <code>ActiveRecord::Base.connection.select_value</code> calls return values typed according to the data, for example:</p>
  
  <pre><code>&gt; ActiveRecord::Base.connection.select_value("SELECT COUNT(*) FROM errors")
  =&gt; 86
  &gt; ActiveRecord::Base.connection.select_value("SELECT exception FROM errors where id=565")
  =&gt; "TechTalk.Genome.SqlExecutionException"
  &gt; ActiveRecord::Base.connection.select_value("SELECT id FROM errors where id=565")
  =&gt; 565
  </code></pre>
  
  <p>However, with postgres, <code>connection.select_value</code> always returns a string:</p>
  
  <pre><code>&gt; ActiveRecord::Base.connection.select_value("SELECT COUNT(*) FROM errors")
  =&gt; "1"
  &gt; ActiveRecord::Base.connection.select_value("SELECT id FROM errors")
  =&gt; "1"
  &gt; ActiveRecord::Base.connection.select_value("SELECT source FROM errors limit 1")
  =&gt; "webapp"
  </code></pre>
  
  <p>This broke a few unit tests, and while those are fixable, I'm certain we have other code relying on these return values. <strong>Is there a way to get properly-typed return values from <code>connection.select_value</code> when using postgres?</strong></p>