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.
This commit is contained in:
parent
6170a2a502
commit
49b617f68c
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user