aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/schema
diff options
context:
space:
mode:
authorLarry Reid <lcreid@jadesystems.ca>2018-07-16 10:44:55 -0700
committerLarry Reid <lcreid@jadesystems.ca>2018-07-23 14:53:27 -0700
commit332e7601a98ebff6a7494a556c7fe97c5691f085 (patch)
treedd60a40250979168ca972db33a189774dc5e75e5 /activerecord/test/schema
parentbd139a59405044c27bf367cde671e4bdbf7ccb57 (diff)
downloadrails-332e7601a98ebff6a7494a556c7fe97c5691f085.tar.gz
rails-332e7601a98ebff6a7494a556c7fe97c5691f085.tar.bz2
rails-332e7601a98ebff6a7494a556c7fe97c5691f085.zip
Fix circular `autosave: true`
Use a variable local to the `save_collection_association` method in `activerecord/lib/active_record/autosave_association.rb`, instead of an instance variable. Prior to this PR, when there was a circular series of `autosave: true` associations, the callback for a `has_many` association was run while another instance of the same callback on the same association hadn't finished running. When control returned to the first instance of the callback, the instance variable had changed, and subsequent associated records weren't saved correctly. Specifically, the ID field for the `belongs_to` corresponding to the `has_many` was `nil`. Remove unnecessary test and comments. Fixes #28080.
Diffstat (limited to 'activerecord/test/schema')
-rw-r--r--activerecord/test/schema/schema.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb
index 266e55f682..02520fc0cc 100644
--- a/activerecord/test/schema/schema.rb
+++ b/activerecord/test/schema/schema.rb
@@ -772,6 +772,24 @@ ActiveRecord::Schema.define do
t.integer :lock_version, default: 0
end
+ disable_referential_integrity do
+ create_table :seminars, force: :cascade do |t|
+ t.string :name
+ end
+
+ create_table :sessions, force: :cascade do |t|
+ t.date :start_date
+ t.date :end_date
+ t.string :name
+ end
+
+ create_table :sections, force: :cascade do |t|
+ t.string :short_name
+ t.belongs_to :session, foreign_key: true
+ t.belongs_to :seminar, foreign_key: true
+ end
+ end
+
create_table :shape_expressions, force: true do |t|
t.string :paint_type
t.integer :paint_id