diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index <HASH>..<HASH> 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -1018,7 +1018,7 @@ class RelationTest < ActiveRecord::TestCase
   end
 
   def test_update_all_with_joins_and_offset_and_order
-    all_comments = Comment.joins(:post).where('posts.id' => posts(:welcome).id).order('posts.id')
+    all_comments = Comment.joins(:post).where('posts.id' => posts(:welcome).id).order('posts.id', 'comments.id')
     count        = all_comments.count
     comments     = all_comments.offset(1)
Ensure correct ordering of results in test_update_all_with_joins_and_offset_and_order

Last two asserts in this test assume that all_comments are ordered by posts.id and then by comments.id therefore additional ordering is added. Without it test was failing on Oracle which returned results in different order.