aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorCade Truitt <cadetruitt@gmail.com>2014-07-02 20:09:05 -0500
committerCade Truitt <cadetruitt@gmail.com>2014-07-02 20:21:36 -0500
commitc8e48f08d528c0e4537bf1df1adac1fa8f4f48ff (patch)
treefa232948dc2392cc6fa846377cb167fc494f327d /activerecord/lib/active_record
parentbeab403fc31199bbb01f1e6e1ba0f839af047afe (diff)
downloadrails-c8e48f08d528c0e4537bf1df1adac1fa8f4f48ff.tar.gz
rails-c8e48f08d528c0e4537bf1df1adac1fa8f4f48ff.tar.bz2
rails-c8e48f08d528c0e4537bf1df1adac1fa8f4f48ff.zip
Add `:all` argument to `count` in `reset_counters`
Prior to this fix, if an association had a scope with a `select`, calls to `reset_counters` would generate invalid SQL and throw: ActiveRecord::StatementInvalid: [$DB_ADAPTER]: wrong number of arguments to function COUNT() References #10710, #13648
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/counter_cache.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/counter_cache.rb b/activerecord/lib/active_record/counter_cache.rb
index 05c4b13016..a33c7c64a7 100644
--- a/activerecord/lib/active_record/counter_cache.rb
+++ b/activerecord/lib/active_record/counter_cache.rb
@@ -38,7 +38,7 @@ module ActiveRecord
counter_name = reflection.counter_cache_column
stmt = unscoped.where(arel_table[primary_key].eq(object.id)).arel.compile_update({
- arel_table[counter_name] => object.send(counter_association).count
+ arel_table[counter_name] => object.send(counter_association).count(:all)
}, primary_key)
connection.update stmt
end