diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2017-07-16 21:03:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-16 21:03:29 +0200 |
commit | 919b55d9747f69c566616d740616d11ef2db8c58 (patch) | |
tree | 48039fb65268710d1b0586fefd7c8a8696448534 /activerecord/lib/active_record | |
parent | c74820d516bdb731a3df3c94192a542abb6c393b (diff) | |
parent | d476553d1cdeee0805585c2d4e2e6ee6be841288 (diff) | |
download | rails-919b55d9747f69c566616d740616d11ef2db8c58.tar.gz rails-919b55d9747f69c566616d740616d11ef2db8c58.tar.bz2 rails-919b55d9747f69c566616d740616d11ef2db8c58.zip |
Merge pull request #29814 from kamipo/dont_cache_scope_for_create
Don't cache `scope_for_create`
Diffstat (limited to 'activerecord/lib/active_record')
3 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations/association.rb b/activerecord/lib/active_record/associations/association.rb index 6acf831759..c166cfd68f 100644 --- a/activerecord/lib/active_record/associations/association.rb +++ b/activerecord/lib/active_record/associations/association.rb @@ -171,7 +171,7 @@ module ActiveRecord skip_assign = [reflection.foreign_key, reflection.type].compact assigned_keys = record.changed_attribute_names_to_save assigned_keys += except_from_scope_attributes.keys.map(&:to_s) - attributes = scope_for_create.except(*(assigned_keys - skip_assign)) + attributes = scope_for_create.except!(*(assigned_keys - skip_assign)) record.send(:_assign_attributes, attributes) if attributes.any? set_inverse_instance(record) end diff --git a/activerecord/lib/active_record/associations/singular_association.rb b/activerecord/lib/active_record/associations/singular_association.rb index 4896afcca7..66993b9bf7 100644 --- a/activerecord/lib/active_record/associations/singular_association.rb +++ b/activerecord/lib/active_record/associations/singular_association.rb @@ -31,7 +31,7 @@ module ActiveRecord private def scope_for_create - super.except(klass.primary_key) + super.except!(klass.primary_key) end def find_target diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 23cb1baaed..c5d98e970a 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -556,7 +556,7 @@ module ActiveRecord end def reset - @to_sql = @scope_for_create = @arel = @loaded = @should_eager_load = nil + @to_sql = @arel = @loaded = @should_eager_load = nil @records = [].freeze @offsets = {} self @@ -590,7 +590,7 @@ module ActiveRecord end def scope_for_create - @scope_for_create ||= where_values_hash.merge!(create_with_value.stringify_keys) + where_values_hash.merge!(create_with_value.stringify_keys) end # Returns true if relation needs eager loading. |