Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move methods from association to relation finder methods.

  • Loading branch information...
commit fc2e25734a175641595db9612d3fb5371cb8aa2c 1 parent 90a4709
@miloops miloops authored
View
9 activerecord/lib/active_record/associations.rb
@@ -1673,15 +1673,6 @@ def create_has_and_belongs_to_many_reflection(association_id, options, &extensio
reflection
end
- def using_limitable_reflections?(reflections)
- reflections.collect(&:collection?).length.zero?
- 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 add_association_callbacks(association_name, options)
callbacks = %w(before_add after_add before_remove after_remove)
callbacks.each do |callback_name|
View
13 activerecord/lib/active_record/relation/finder_methods.rb
@@ -175,7 +175,7 @@ def construct_relation_for_association_calculations
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 @@ def apply_join_dependency(relation, join_dependency)
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 @@ def find_last
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
Please sign in to comment.
Something went wrong with that request. Please try again.