aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorYasuo Honda <yasuo.honda@gmail.com>2017-09-13 18:34:50 +0000
committerYasuo Honda <yasuo.honda@gmail.com>2017-09-13 22:55:13 +0000
commitaaed081e08c1a04eabeec9fa5edab5e0760f46e2 (patch)
tree2d1ccc24366dc44716b8cf9da4a77ff6285d99fd /activerecord
parent7d5399379cb9ac2d3ffafa28fdc844d7b6c18ab8 (diff)
downloadrails-aaed081e08c1a04eabeec9fa5edab5e0760f46e2.tar.gz
rails-aaed081e08c1a04eabeec9fa5edab5e0760f46e2.tar.bz2
rails-aaed081e08c1a04eabeec9fa5edab5e0760f46e2.zip
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.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/relation/or_test.rb2
1 files changed, 1 insertions, 1 deletions
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