mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Fix order method to accept relation attributes.
Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
@@ -137,7 +137,7 @@ module ActiveRecord
|
||||
|
||||
arel = arel.group(*@group_values.uniq.select{|g| g.present?}) if @group_values.present?
|
||||
|
||||
arel = arel.order(*@order_values.uniq.select{|o| o.present?}.map(&:to_s)) if @order_values.present?
|
||||
arel = arel.order(*@order_values.uniq.select{|o| o.present?}) if @order_values.present?
|
||||
|
||||
selects = @select_values.uniq
|
||||
|
||||
|
||||
@@ -503,13 +503,13 @@ class RelationTest < ActiveRecord::TestCase
|
||||
|
||||
def test_many
|
||||
posts = Post.scoped
|
||||
|
||||
|
||||
assert_queries(2) do
|
||||
assert posts.many? # Uses COUNT()
|
||||
assert posts.many? {|p| p.id > 0 }
|
||||
assert ! posts.many? {|p| p.id < 2 }
|
||||
end
|
||||
|
||||
|
||||
assert posts.loaded?
|
||||
end
|
||||
|
||||
@@ -593,4 +593,8 @@ class RelationTest < ActiveRecord::TestCase
|
||||
assert_equal "lifo", relation.author
|
||||
assert_equal "lifo", relation.limit(1).author
|
||||
end
|
||||
|
||||
def test_order_by_relation_attribute
|
||||
assert_equal Post.order(Post.arel_table[:title]).all, Post.order("title").all
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user