diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-01-19 15:22:09 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-01-19 15:22:09 +0530 |
commit | b9599502c9e738a5a1513e75d08f8d40ed408265 (patch) | |
tree | afad18ebc168c3d3c511626255a58c7c306f95a5 /activerecord/lib/active_record/relation | |
parent | 71d67fc6bd504956bce66e274e6228dd00a814c1 (diff) | |
download | rails-b9599502c9e738a5a1513e75d08f8d40ed408265.tar.gz rails-b9599502c9e738a5a1513e75d08f8d40ed408265.tar.bz2 rails-b9599502c9e738a5a1513e75d08f8d40ed408265.zip |
Add Relation#construct_relation_for_association_calculations for calculations with includes
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r-- | activerecord/lib/active_record/relation/finder_methods.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index 980c5796f3..c48c8fe828 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -53,6 +53,12 @@ module ActiveRecord [] end + def construct_relation_for_association_calculations + including = (@eager_load_values + @includes_values).uniq + join_dependency = ActiveRecord::Associations::ClassMethods::JoinDependency.new(@klass, including, arel.joins(arel)) + construct_relation_for_association_find(join_dependency) + end + def construct_relation_for_association_find(join_dependency) relation = except(:includes, :eager_load, :preload, :select).select(@klass.send(:column_aliases, join_dependency)) |