Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix aggregate functions to return numeric value consistently even on custom attribute type #39039

Merged
merged 1 commit into from
Apr 25, 2020

Commits on Apr 25, 2020

  1. Fix aggregate functions to return numeric value consistently even on …

    …custom attribute type
    
    Currently, `count` and `average` always returns numeric value, but
    `sum`, `maximum`, and `minimum` not always return numeric value if
    aggregated on custom attribute type.
    
    I think that inconsistent behavior is surprising:
    
    ```ruby
    # All adapters except postgresql adapter are affected
    # by custom type casting.
    
    Book.group(:status).sum(:status)
    # => { "proposed" => "proposed", "published" => nil }
    ```
    
    That is caused by fallback looking up cast type to `type_for(column)`.
    Now all supported adapters can return numeric value without that
    fallback, so I think we can remove that, it will also fix aggregate
    functions to return numeric value consistently.
    kamipo committed Apr 25, 2020
    Configuration menu
    Copy the full SHA
    89e1dd6 View commit details
    Browse the repository at this point in the history