From a38f28fff1e9e3faeeb22ac9b7c6b3cdcb7e2b29 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 17 Mar 2007 15:48:47 +0000 Subject: Base.update_all :order and :limit options. Useful for MySQL updates that must be ordered to avoid violating unique constraints. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6440 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/test/base_test.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'activerecord/test/base_test.rb') diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb index cbc144f57a..c3ae9a08b9 100755 --- a/activerecord/test/base_test.rb +++ b/activerecord/test/base_test.rb @@ -569,6 +569,12 @@ class BasicsTest < Test::Unit::TestCase end end + if current_adapter?(:MysqlAdapter) + def test_update_all_with_order_and_limit + assert_equal 1, Topic.update_all("content = 'bulk updated!'", nil, :limit => 1, :order => 'id DESC') + end + end + def test_update_many topic_data = { 1 => { "content" => "1 updated" }, 2 => { "content" => "2 updated" } } updated = Topic.update(topic_data.keys, topic_data.values) -- cgit v1.2.3