rails/rails — pull request #10710 by senny (2013-05-21 12:40:33+00:00)
Title: Remove column restrictions for `#count`, let the database raise if the SQL is invalid.

Fixes #5554

Previously the code path for `#count` used some [validation logic](https://github.com/rails/rails/blob/54122067acaad39b277a5363c6d11d6804c7bf6b/activerecord/lib/active_record/relation/calculations.rb#L389-L394) and used to fall back on `#count(:all)`. This prevented the execution of some specific count queries.

This patch gets rid of the validation logic and let's the database decide if the query is valid or not. One backwards incompatible result of this patch is the following:

```ruby
relation = User.select("id, name")

# later in the code
relation.count
```

This count will now blow up because it you can't count on two columns. The solution is to specify the counting column explicitly:

```ruby
relation.count(:all)
```