aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/attribute.rb2
-rw-r--r--activerecord/lib/active_record/relation/delegation.rb2
-rw-r--r--activerecord/test/cases/base_test.rb7
3 files changed, 9 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/attribute.rb b/activerecord/lib/active_record/attribute.rb
index 95b3adae5f..380593e809 100644
--- a/activerecord/lib/active_record/attribute.rb
+++ b/activerecord/lib/active_record/attribute.rb
@@ -65,7 +65,7 @@ module ActiveRecord
def with_value_from_user(value)
type.assert_valid_value(value)
- self.class.from_user(name, value, type, self)
+ self.class.from_user(name, value, type, original_attribute || self)
end
def with_value_from_database(value)
diff --git a/activerecord/lib/active_record/relation/delegation.rb b/activerecord/lib/active_record/relation/delegation.rb
index b4147ce434..e1c36982dd 100644
--- a/activerecord/lib/active_record/relation/delegation.rb
+++ b/activerecord/lib/active_record/relation/delegation.rb
@@ -38,7 +38,7 @@ module ActiveRecord
delegate :to_xml, :encode_with, :length, :collect, :map, :each, :all?, :include?, :to_ary, :join,
:[], :&, :|, :+, :-, :sample, :reverse, :compact, :in_groups, :in_groups_of,
- :shuffle, :split, to: :records
+ :shuffle, :split, :index, to: :records
delegate :table_name, :quoted_table_name, :primary_key, :quoted_primary_key,
:connection, :columns_hash, to: :klass
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index cd896e5948..bf2c13cfac 100644
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -115,6 +115,13 @@ class BasicsTest < ActiveRecord::TestCase
end
end
+ def test_many_mutations
+ car = Car.new name: "<3<3<3"
+ car.engines_count = 0
+ 20_000.times { car.engines_count += 1 }
+ assert car.save
+ end
+
def test_limit_without_comma
assert_equal 1, Topic.limit("1").to_a.length
assert_equal 1, Topic.limit(1).to_a.length