Changeset 6440
- Timestamp:
- 03/17/07 15:48:47 (1 year ago)
- Files:
-
- trunk/activerecord/CHANGELOG (modified) (1 diff)
- trunk/activerecord/lib/active_record/base.rb (modified) (1 diff)
- trunk/activerecord/test/base_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/CHANGELOG
r6439 r6440 1 1 *SVN* 2 3 * Base.update_all :order and :limit options. Useful for MySQL updates that must be ordered to avoid violating unique constraints. [Jeremy Kemper] 2 4 3 5 * Remove deprecated object transactions. People relying on this functionality should install the object_transactions plugin at http://code.bitsweat.net/svn/object_transactions. Closes #5637 [Koz, Jeremy Kemper] trunk/activerecord/lib/active_record/base.rb
r6420 r6440 502 502 # A subset of the records can be selected by specifying +conditions+. Example: 503 503 # Billing.update_all "category = 'authorized', approved = 1", "author = 'David'" 504 def update_all(updates, conditions = nil) 504 # 505 # Optional :order and :limit options may be given as the third parameter, 506 # but their behavior is database-specific. 507 def update_all(updates, conditions = nil, options = {}) 505 508 sql = "UPDATE #{table_name} SET #{sanitize_sql_for_assignment(updates)} " 506 add_conditions!(sql, conditions, scope(:find)) 509 scope = scope(:find) 510 add_conditions!(sql, conditions, scope) 511 add_order!(sql, options[:order], scope) 512 add_limit!(sql, options, scope) 507 513 connection.update(sql, "#{name} Update") 508 514 end trunk/activerecord/test/base_test.rb
r6348 r6440 570 570 end 571 571 572 if current_adapter?(:MysqlAdapter) 573 def test_update_all_with_order_and_limit 574 assert_equal 1, Topic.update_all("content = 'bulk updated!'", nil, :limit => 1, :order => 'id DESC') 575 end 576 end 577 572 578 def test_update_many 573 579 topic_data = { 1 => { "content" => "1 updated" }, 2 => { "content" => "2 updated" } }