Changeset 4462
- Timestamp:
- 06/20/06 01:58:36 (2 years ago)
- Files:
-
- trunk/activerecord/CHANGELOG (modified) (1 diff)
- trunk/activerecord/lib/active_record.rb (modified) (2 diffs)
- trunk/activerecord/lib/active_record/base.rb (modified) (1 diff)
- trunk/activerecord/lib/active_record/locking (added)
- trunk/activerecord/lib/active_record/locking.rb (deleted)
- trunk/activerecord/lib/active_record/locking/optimistic.rb (added)
- trunk/activerecord/lib/active_record/locking/pessimistic.rb (added)
- trunk/activerecord/test/locking_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/CHANGELOG
r4460 r4462 1 1 *SVN* 2 2 3 * Row locking. Provide a locking clause with the :lock finder option or true for the default "FOR UPDATE". [Shugo Maeda]3 * Row locking. Provide a locking clause with the :lock finder option or true for the default "FOR UPDATE". Use the #lock method to obtain a row lock on a single reload (reloads the record with :lock => true). [Shugo Maeda] 4 4 # Obtain an exclusive lock on person 1 so we can safely increment visits. 5 5 Person.transaction do trunk/activerecord/lib/active_record.rb
r4461 r4462 47 47 require 'active_record/acts/tree' 48 48 require 'active_record/acts/nested_set' 49 require 'active_record/locking' 49 require 'active_record/locking/optimistic' 50 require 'active_record/locking/pessimistic' 50 51 require 'active_record/migration' 51 52 require 'active_record/schema' … … 56 57 include ActiveRecord::Validations 57 58 include ActiveRecord::Locking::Optimistic 59 include ActiveRecord::Locking::Pessimistic 58 60 include ActiveRecord::Callbacks 59 61 include ActiveRecord::Observing trunk/activerecord/lib/active_record/base.rb
r4460 r4462 1542 1542 1543 1543 # Reloads the attributes of this object from the database. 1544 def reload 1544 # The optional options argument is passed to find when reloading so you 1545 # may do e.g. record.reload(:lock => true) to reload the same record with 1546 # an exclusive row lock. 1547 def reload(options = nil) 1545 1548 clear_aggregation_cache 1546 1549 clear_association_cache 1547 @attributes.update(self.class.find(self.id ).instance_variable_get('@attributes'))1550 @attributes.update(self.class.find(self.id, options).instance_variable_get('@attributes')) 1548 1551 self 1549 1552 end trunk/activerecord/test/locking_test.rb
r4460 r4462 83 83 end 84 84 85 # Locking a record reloads it. 86 def test_sane_lock_method 87 assert_nothing_raised do 88 Person.transaction do 89 person = Person.find 1 90 old, person.first_name = person.first_name, 'fooman' 91 person.lock! 92 assert_equal old, person.first_name 93 end 94 end 95 end 96 85 97 if current_adapter?(:PostgreSQLAdapter) 86 98 def test_no_locks_no_wait