Skip to content

Commit

Permalink
fix test so that NULLS are always last
Browse files Browse the repository at this point in the history
databases treat `NULL` differently when ordering, so make them behave
the same by explcitly specifying how to order `NULL`
  • Loading branch information
doits committed Oct 4, 2024
1 parent 03fe657 commit 1a76919
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1a76919

Please sign in to comment.