diff options
author | Laerti <laertis.pappas@gmail.com> | 2019-01-15 15:03:20 +0100 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2019-01-15 23:03:20 +0900 |
commit | 41ffddbc8b7faec66a26bd48dfd36a9def6cc23f (patch) | |
tree | 578282157b3386a787237e9f8fa934010aa6233c /activerecord/test/models | |
parent | e4213e7c682f2b4bf19383ea1af1681c81c96ac5 (diff) | |
download | rails-41ffddbc8b7faec66a26bd48dfd36a9def6cc23f.tar.gz rails-41ffddbc8b7faec66a26bd48dfd36a9def6cc23f.tar.bz2 rails-41ffddbc8b7faec66a26bd48dfd36a9def6cc23f.zip |
Refs #28025 nullify *_type column on polymorphic associations on :nu… (#28078)
This PR addresses the issue described in #28025. On `dependent: :nullify` strategy only the foreign key of the relation is nullified. However on polymorphic associations the `*_type` column is not nullified leaving the record with a NULL `*_id` but the `*_type` column is present.
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/drink_designer.rb | 6 | ||||
-rw-r--r-- | activerecord/test/models/person.rb | 5 |
2 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/test/models/drink_designer.rb b/activerecord/test/models/drink_designer.rb index eb6701b84e..8258408f35 100644 --- a/activerecord/test/models/drink_designer.rb +++ b/activerecord/test/models/drink_designer.rb @@ -4,5 +4,11 @@ class DrinkDesigner < ActiveRecord::Base has_one :chef, as: :employable end +class DrinkDesignerWithPolymorphicDependentNullifyChef < ActiveRecord::Base + self.table_name = "drink_designers" + + has_one :chef, as: :employable, dependent: :nullify +end + class MocktailDesigner < DrinkDesigner end diff --git a/activerecord/test/models/person.rb b/activerecord/test/models/person.rb index 5cba1e440e..c3d15a571a 100644 --- a/activerecord/test/models/person.rb +++ b/activerecord/test/models/person.rb @@ -62,6 +62,11 @@ class PersonWithDependentNullifyJobs < ActiveRecord::Base has_many :jobs, source: :job, through: :references, dependent: :nullify end +class PersonWithPolymorphicDependentNullifyComments < ActiveRecord::Base + self.table_name = "people" + has_many :comments, as: :author, dependent: :nullify +end + class LoosePerson < ActiveRecord::Base self.table_name = "people" self.abstract_class = true |