rails/rails — pull request #13334 by gregolsen (2013-12-16 09:07:39+00:00)
Title: Incorrect infinity and NaN conversion to Ruby values in postgresql adapter

Active Record successfully stores Ruby Infinity value in a Postgresql DB column of double precision type.
However it fails to convert it back to Ruby Float::INFINITY when the record is fetched from DB.
The issue can be illustrated with the code below:
While the value is correctly stored as 'Infinity' when it is accessed through AR instance - it's converted to 0.

It looks like the problem is in the type cast which is simply `to_f` for the float values.
Thus - in case 'Infinity' or 'NaN' in database it converts it to 0.

The naive fix in this PR is rather to start the discussion and clarify is this really an issue or I'm just missing something.

```
require 'active_record'
require 'pg'

ActiveRecord::Base.establish_connection(
database: 'infinity',
adapter: 'postgresql',
username: 'postgres'
)

ActiveRecord::Base.connection.instance_eval do
create_table :points, force: true do |t|
t.column :value, :float
end
end

class Point < ActiveRecord::Base; end
infinity = 1.0/0
Point.create(value: infinity)
point = Point.first
p Point.connection.execute("select value from points limit 1").to_a #=> [{"value"=>"Infinity"}]
p point.read_attribute_before_type_cast('value') #=> "Infinity"
p point.value #=> 0.0 when it should be Float::INFINITY
```