aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2010-03-23 12:56:35 -0300
committerEmilio Tagua <miloops@gmail.com>2010-03-25 15:47:06 -0300
commitfc2e25734a175641595db9612d3fb5371cb8aa2c (patch)
tree1ab07ad36a4886821de3cd93c3fa81cb9ce15659 /activerecord/lib/active_record/relation
parent90a4709601873583d32c422c3a6422ef56bbc81b (diff)
downloadrails-fc2e25734a175641595db9612d3fb5371cb8aa2c.tar.gz
rails-fc2e25734a175641595db9612d3fb5371cb8aa2c.tar.bz2
rails-fc2e25734a175641595db9612d3fb5371cb8aa2c.zip
Move methods from association to relation finder methods.
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r--activerecord/lib/active_record/relation/finder_methods.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index d6d3d66642..c1cce679b6 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -175,7 +175,7 @@ module ActiveRecord
end
def construct_relation_for_association_find(join_dependency)
- relation = except(:includes, :eager_load, :preload, :select).select(@klass.send(:column_aliases, join_dependency))
+ relation = except(:includes, :eager_load, :preload, :select).select(column_aliases(join_dependency))
apply_join_dependency(relation, join_dependency)
end
@@ -184,7 +184,7 @@ module ActiveRecord
relation = association.join_relation(relation)
end
- limitable_reflections = @klass.send(:using_limitable_reflections?, join_dependency.reflections)
+ limitable_reflections = using_limitable_reflections?(join_dependency.reflections)
if !limitable_reflections && relation.limit_value
limited_id_condition = construct_limited_ids_condition(relation.except(:select))
@@ -311,5 +311,14 @@ module ActiveRecord
end
end
+ def column_aliases(join_dependency)
+ join_dependency.joins.collect{|join| join.column_names_with_alias.collect{|column_name, aliased_name|
+ "#{connection.quote_table_name join.aliased_table_name}.#{connection.quote_column_name column_name} AS #{aliased_name}"}}.flatten.join(", ")
+ end
+
+ def using_limitable_reflections?(reflections)
+ reflections.collect(&:collection?).length.zero?
+ end
+
end
end