From 1dcb1ccc9d3d4f41e8f1a76ff3465f708189dd2f Mon Sep 17 00:00:00 2001 From: Ben Woosley Date: Fri, 10 May 2013 11:42:24 +0200 Subject: Simplify conditions within apply_join_dependency --- activerecord/lib/active_record/relation/finder_methods.rb | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index 531343782e..9a774b5abc 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -231,16 +231,12 @@ module ActiveRecord relation = association.join_relation(relation) end - limitable_reflections = using_limitable_reflections?(join_dependency.reflections) - - if !limitable_reflections && relation.limit_value - limited_id_condition = construct_limited_ids_condition(relation) - relation = relation.where(limited_id_condition) + if using_limitable_reflections?(join_dependency.reflections) + relation + else + relation = relation.where(construct_limited_ids_condition(relation)) if relation.limit_value + relation.except(:limit, :offset) end - - relation = relation.except(:limit, :offset) unless limitable_reflections - - relation end def construct_limited_ids_condition(relation) -- cgit v1.2.3