aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/schema
diff options
context:
space:
mode:
authorDavid Peter <david.a.peter@gmail.com>2012-01-16 18:06:14 -0800
committerDavid Peter <david.a.peter@gmail.com>2012-01-16 19:06:45 -0800
commitee013a503db125b8be54daec7096e2d26bb6228c (patch)
treeccb096e2f9fe053ffe1538b9276c6632973abda8 /activerecord/test/schema
parent21afd9b96d70d1e2b1cffdfb60f7ec64ab240472 (diff)
downloadrails-ee013a503db125b8be54daec7096e2d26bb6228c.tar.gz
rails-ee013a503db125b8be54daec7096e2d26bb6228c.tar.bz2
rails-ee013a503db125b8be54daec7096e2d26bb6228c.zip
Fix bug where reset_counters resets the wrong counter cache.
If a model belongs_to two associations with the same class, then reset_counters will reset the wrong counter cache. Finding the right reflection should use the foreign_key instead, which should be unique.
Diffstat (limited to 'activerecord/test/schema')
-rw-r--r--activerecord/test/schema/schema.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb
index 11378c12e5..e2cd7ce9e4 100644
--- a/activerecord/test/schema/schema.rb
+++ b/activerecord/test/schema/schema.rb
@@ -213,6 +213,16 @@ ActiveRecord::Schema.define do
t.integer :access_level, :default => 1
end
+ create_table :dog_lovers, :force => true do |t|
+ t.integer :trained_dogs_count, :default => 0
+ t.integer :bred_dogs_count, :default => 0
+ end
+
+ create_table :dogs, :force => true do |t|
+ t.integer :trainer_id
+ t.integer :breeder_id
+ end
+
create_table :edges, :force => true, :id => false do |t|
t.column :source_id, :integer, :null => false
t.column :sink_id, :integer, :null => false