rails/rails — Issue #5285: Sum of BigDecimal w/ group by returning a String
Author: Adman65
Created: 2012-03-05 17:16:05+00:00
State: open

I have a simple method to calculate the total of a deal by summing it's line items:

```ruby
def self.totals
sum :price, :joins => :line_items, :group => :currency
end
```

`price` is a big decimal column.

Here's the generated SQL:

```
SELECT SUM(price) AS sum_price, currency AS currency FROM "deals" INNER JOIN "line_items" ON "line_items"."deal_id" = "deals"."id" GROUP BY currency
```

And the result

```
{"USD"=>"1200000.00"}
```

Shouldn't the value be a Float or some other numeric type?