mirror of https://github.com/rails/rails
Changed the order of Association constraints from where->order->unscope to unscope->where->order
This commit is contained in:
parent
d68e81afa0
commit
dda4f60890
|
@ -147,9 +147,9 @@ module ActiveRecord
|
|||
scope.includes! item.includes_values
|
||||
end
|
||||
|
||||
scope.unscope!(*item.unscope_values)
|
||||
scope.where_clause += item.where_clause
|
||||
scope.order_values |= item.order_values
|
||||
scope.unscope!(*item.unscope_values)
|
||||
end
|
||||
|
||||
reflection = reflection.next
|
||||
|
|
|
@ -2358,4 +2358,8 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
|
|||
assert_equal [bulb.id], car.bulb_ids
|
||||
assert_no_queries { car.bulb_ids }
|
||||
end
|
||||
|
||||
def test_has_many_association_with_rewhere
|
||||
assert_equal 'Don\'t think too hard', posts(:welcome).comments_with_rewhere.first.body
|
||||
end
|
||||
end
|
||||
|
|
|
@ -67,6 +67,7 @@ class Post < ActiveRecord::Base
|
|||
end
|
||||
|
||||
has_many :comments_with_extend_2, extend: [NamedExtension, NamedExtension2], class_name: "Comment", foreign_key: "post_id"
|
||||
has_many :comments_with_rewhere, -> { rewhere(post_id: 2) }, class_name: "Comment"
|
||||
|
||||
has_many :author_favorites, :through => :author
|
||||
has_many :author_categorizations, :through => :author, :source => :categorizations
|
||||
|
|
Loading…
Reference in New Issue