diff options
author | Ben Woosley <ben.woosley@gmail.com> | 2013-05-10 11:42:24 +0200 |
---|---|---|
committer | Ben Woosley <ben.woosley@gmail.com> | 2013-05-10 17:46:04 +0200 |
commit | 1dcb1ccc9d3d4f41e8f1a76ff3465f708189dd2f (patch) | |
tree | 46c2708a1ef07d1e70777c3b6fc31e782c4fc0e4 /activerecord | |
parent | cd04a99ba4b5227fb103b6d4e7504c770833e612 (diff) | |
download | rails-1dcb1ccc9d3d4f41e8f1a76ff3465f708189dd2f.tar.gz rails-1dcb1ccc9d3d4f41e8f1a76ff3465f708189dd2f.tar.bz2 rails-1dcb1ccc9d3d4f41e8f1a76ff3465f708189dd2f.zip |
Simplify conditions within apply_join_dependency
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/relation/finder_methods.rb | 14 |
1 files 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) |