提交 49b617f6 编写于 作者: R Ryuta Kamizono

Restore an ability that `reorder` with `first` taking non-deterministic result

Actually, `first` taking non-deterministic result is considered a bug to
me. But changing the behavior should not be happened in rc2.

I've restored the behavior for 6.0, and then will deprecate that in 6.1.

Fixes #36802.
上级 6170a2a5
......@@ -372,7 +372,7 @@ def reorder(*args)
# Same as #reorder but operates on relation in-place instead of copying.
def reorder!(*args) # :nodoc:
preprocess_order_args(args)
preprocess_order_args(args) unless args.all?(&:blank?)
self.reordering_value = true
self.order_values = args
......
......@@ -1737,6 +1737,20 @@ def test_reverse_order_with_reorder_nil_removes_the_order
assert_nil relation.order_values.first
end
def test_reorder_with_first
sql_log = capture_sql do
assert Post.order(:title).reorder(nil).first
end
assert sql_log.all? { |sql| !/order by/i.match?(sql) }, "ORDER BY was used in the query: #{sql_log}"
end
def test_reorder_with_take
sql_log = capture_sql do
assert Post.order(:title).reorder(nil).take
end
assert sql_log.all? { |sql| !/order by/i.match?(sql) }, "ORDER BY was used in the query: #{sql_log}"
end
def test_presence
topics = Topic.all
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册