Skip to content

AR aggregate calculations always return BigDecimal #58

@yolk

Description

@yolk

When calling sum or average on a AR-Model it always returns a BigDecimal, even if the used attribute is of type INT:

TimeEntry.sum(:minutes)
=> #<BigDecimal:105dade18,'0.10091662E8',9(18)>

TimeEntry.first.minutes
=> 123

With the mysql gem sum returns an integer:

TimeEntry.sum(:minutes)
=> 10091662

This also occurs when using average, but not maximum or minimum. Is this behaviour intended?

I testet with Rails 3.0.0 on ruby-1.9.2.p0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions