提交 ce102e3a 编写于 作者: R Rick Olson

Ensure optimistic locking handles nil #lock_version values properly. Closes #10510 [rick]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8395 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 abd7cf34
*SVN*
* Ensure optimistic locking handles nil #lock_version values properly. Closes #10510 [rick]
* Make the Fixtures Test::Unit enhancements more supporting for double-loaded test cases. Closes #10379 [brynary]
* Fix that validates_acceptance_of still works for non-existent tables (useful for bootstrapping new databases). Closes #10474 [hasmanyjosh]
......
......@@ -70,7 +70,7 @@ def update_with_lock #:nodoc:
return update_without_lock unless locking_enabled?
lock_col = self.class.locking_column
previous_value = send(lock_col)
previous_value = send(lock_col).to_i
send(lock_col + '=', previous_value + 1)
begin
......
......@@ -64,6 +64,15 @@ def test_lock_new
assert_raises(ActiveRecord::StaleObjectError) { p2.save! }
end
def test_lock_new_with_nil
p1 = Person.new(:first_name => 'anika')
p1.save!
p1.lock_version = nil # simulate bad fixture or column with no default
p1.save!
assert_equal 1, p1.lock_version
end
def test_lock_column_name_existing
t1 = LegacyThing.find(1)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册