Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8395

Show
Ignore:
Timestamp:
12/15/07 01:45:30 (1 year ago)
Author:
rick
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/CHANGELOG

    r8392 r8395  
    11*SVN* 
     2 
     3* Ensure optimistic locking handles nil #lock_version values properly.  Closes #10510 [rick] 
    24 
    35* Make the Fixtures Test::Unit enhancements more supporting for double-loaded test cases.  Closes #10379 [brynary] 
  • trunk/activerecord/lib/active_record/locking/optimistic.rb

    r8156 r8395  
    7171 
    7272          lock_col = self.class.locking_column 
    73           previous_value = send(lock_col) 
     73          previous_value = send(lock_col).to_i 
    7474          send(lock_col + '=', previous_value + 1) 
    7575 
  • trunk/activerecord/test/locking_test.rb

    r8230 r8395  
    6565    assert_raises(ActiveRecord::StaleObjectError) { p2.save! } 
    6666  end 
     67   
     68  def test_lock_new_with_nil 
     69    p1 = Person.new(:first_name => 'anika') 
     70    p1.save! 
     71    p1.lock_version = nil # simulate bad fixture or column with no default 
     72    p1.save! 
     73    assert_equal 1, p1.lock_version 
     74  end 
     75     
    6776 
    6877  def test_lock_column_name_existing