Skip to content

Commit

Permalink
Pass along original attribute to save later recursion
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Aug 14, 2016
1 parent fb99a48 commit b6c0bc9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def forgetting_assignment

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)
Expand Down
7 changes: 7 additions & 0 deletions activerecord/test/cases/base_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ def test_limit_with_comma
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
Expand Down

0 comments on commit b6c0bc9

Please sign in to comment.