aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/relation.rb3
-rw-r--r--activerecord/lib/active_record/relation/finder_methods.rb7
2 files changed, 6 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index cfaf566ec4..8d11fa4e57 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -508,7 +508,8 @@ module ActiveRecord
if eager_loading?
join_dependency = construct_join_dependency
- relation = construct_relation_for_association_find(join_dependency)
+ relation = except :select
+ relation = construct_relation_for_association_find(join_dependency, relation)
end
ast = relation.arel.ast
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index 6ac803afc2..b575d9ad61 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -242,7 +242,8 @@ module ActiveRecord
def find_with_associations
join_dependency = construct_join_dependency
- relation = construct_relation_for_association_find(join_dependency)
+ relation = except :select
+ relation = construct_relation_for_association_find(join_dependency, relation)
if ActiveRecord::NullRelation === relation
[]
else
@@ -260,8 +261,8 @@ module ActiveRecord
apply_join_dependency(self, construct_join_dependency(arel.froms.first))
end
- def construct_relation_for_association_find(join_dependency)
- relation = except(:select).select(join_dependency.columns)
+ def construct_relation_for_association_find(join_dependency, relation = self)
+ relation = relation.select(join_dependency.columns)
apply_join_dependency(relation, join_dependency)
end