aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/persistence_test.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-12-19 18:39:10 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-12-19 18:58:25 +0900
commit1118e2c28913be29d03b8a119cb086fe15dacc39 (patch)
treef4bdf980e275dd3366d9c1bf6af5244b458e422a /activerecord/test/cases/persistence_test.rb
parent67fefbe0c2de5d55b4d30958ce70d659c1c4cf35 (diff)
downloadrails-1118e2c28913be29d03b8a119cb086fe15dacc39.tar.gz
rails-1118e2c28913be29d03b8a119cb086fe15dacc39.tar.bz2
rails-1118e2c28913be29d03b8a119cb086fe15dacc39.zip
Using subselect generated by the connection adapter for `update_all` with `offset`
Most RDBMS (except SQLite) requires subselect for UPDATE with OFFSET, but Arel doesn't support executable subselect generation for MySQL's UPDATE yet. We need to use the subselect generated by the connection adapter for now, it works well. Fixes #30148.
Diffstat (limited to 'activerecord/test/cases/persistence_test.rb')
-rw-r--r--activerecord/test/cases/persistence_test.rb23
1 files changed, 16 insertions, 7 deletions
diff --git a/activerecord/test/cases/persistence_test.rb b/activerecord/test/cases/persistence_test.rb
index 068d80eb3b..3440781fee 100644
--- a/activerecord/test/cases/persistence_test.rb
+++ b/activerecord/test/cases/persistence_test.rb
@@ -59,13 +59,22 @@ class PersistenceTest < ActiveRecord::TestCase
def test_update_all_with_order_and_limit_updates_subset_only
author = authors(:david)
- assert_nothing_raised do
- assert_equal 1, author.posts_sorted_by_id_limited.size
- assert_equal 2, author.posts_sorted_by_id_limited.limit(2).to_a.size
- assert_equal 1, author.posts_sorted_by_id_limited.update_all([ "body = ?", "bulk update!" ])
- assert_equal "bulk update!", posts(:welcome).body
- assert_not_equal "bulk update!", posts(:thinking).body
- end
+ limited_posts = author.posts_sorted_by_id_limited
+ assert_equal 1, limited_posts.size
+ assert_equal 2, limited_posts.limit(2).size
+ assert_equal 1, limited_posts.update_all([ "body = ?", "bulk update!" ])
+ assert_equal "bulk update!", posts(:welcome).body
+ assert_not_equal "bulk update!", posts(:thinking).body
+ end
+
+ def test_update_all_with_order_and_limit_and_offset_updates_subset_only
+ author = authors(:david)
+ limited_posts = author.posts_sorted_by_id_limited.offset(1)
+ assert_equal 1, limited_posts.size
+ assert_equal 2, limited_posts.limit(2).size
+ assert_equal 1, limited_posts.update_all([ "body = ?", "bulk update!" ])
+ assert_equal "bulk update!", posts(:thinking).body
+ assert_not_equal "bulk update!", posts(:welcome).body
end
end