未验证 提交 f5901883 编写于 作者: R Ryuta Kamizono 提交者: GitHub

Merge pull request #40097 from Shopify/ar-reorder-uniq

Call uniq! on the `reorder` arguments.
......@@ -405,6 +405,7 @@ def reorder(*args)
# Same as #reorder but operates on relation in-place instead of copying.
def reorder!(*args) # :nodoc:
preprocess_order_args(args) unless args.all?(&:blank?)
args.uniq!
self.reordering_value = true
self.order_values = args
self
......
......@@ -425,6 +425,11 @@ def test_finding_with_reorder
assert_equal ["The First Topic", "The Second Topic of the day", "The Third Topic of the day", "The Fourth Topic of the day", "The Fifth Topic of the day"], topics_titles
end
def test_reorder_deduplication
topics = Topic.reorder("id desc", "id desc")
assert_equal ["id desc"], topics.order_values
end
def test_finding_with_reorder_by_aliased_attributes
topics = Topic.order("author_name").reorder(:heading)
assert_equal 5, topics.to_a.size
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册