From a0d6b00fa1a745459f01f9dec5589c2d1d1a7691 Mon Sep 17 00:00:00 2001 From: Markus Doits Date: Thu, 12 Sep 2024 21:16:28 +0200 Subject: [PATCH] fix test so that NULLS are always last databases treat `NULL` differently when ordering, so make them behave the same by explcitly specifying how to order `NULL` --- activerecord/test/cases/relation/field_ordered_values_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/test/cases/relation/field_ordered_values_test.rb b/activerecord/test/cases/relation/field_ordered_values_test.rb index 42424a62c4967..f5544b33e81f2 100644 --- a/activerecord/test/cases/relation/field_ordered_values_test.rb +++ b/activerecord/test/cases/relation/field_ordered_values_test.rb @@ -134,7 +134,7 @@ def test_in_order_of_with_array_values_with_nil Book.create!(format: "digital") order = ["ebook", ["paperback", nil, "digital"], "letter"] - books = Book.in_order_of(:format, order).order(format: :desc) + books = Book.in_order_of(:format, order).order(Book.arel_table[:format].desc.nulls_last) assert_equal(["ebook", "paperback", "digital", nil, "letter"], books.map(&:format)) end end