From aaed081e08c1a04eabeec9fa5edab5e0760f46e2 Mon Sep 17 00:00:00 2001 From: Yasuo Honda Date: Wed, 13 Sep 2017 18:34:50 +0000 Subject: Address random `test_or_with_bind_params` failures Reported at https://travis-ci.org/rails/rails/jobs/274370258 - `Post.find([1, 2])` generates this query below: ```sql SELECT "posts".* FROM "posts" WHERE "posts"."id" IN ($1, $2) [["id", 1], ["id", 2]] ``` - `Post.where(id: 1).or(Post.where(id: 2)).to_a` generates this query below: ```sql SELECT "posts".* FROM "posts" WHERE ("posts"."id" = $1 OR "posts"."id" = $2) [["id", 1], ["id", 2]] ``` Most of the time these two queries return the same result but the order of records are not guaranteed from SQL point of view then added `sort` before comparing them. --- activerecord/test/cases/relation/or_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord') diff --git a/activerecord/test/cases/relation/or_test.rb b/activerecord/test/cases/relation/or_test.rb index 955e9fc9ce..7e418f9c7d 100644 --- a/activerecord/test/cases/relation/or_test.rb +++ b/activerecord/test/cases/relation/or_test.rb @@ -31,7 +31,7 @@ module ActiveRecord end def test_or_with_bind_params - assert_equal Post.find([1, 2]), Post.where(id: 1).or(Post.where(id: 2)).to_a + assert_equal Post.find([1, 2]).sort_by(&:id), Post.where(id: 1).or(Post.where(id: 2)).sort_by(&:id) end def test_or_with_null_both -- cgit v1.2.3