aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2010-01-20 01:19:53 +0530
committerPratik Naik <pratiknaik@gmail.com>2010-01-20 01:20:20 +0530
commit42553a98eaa05c703de52147c870e4dd9a3d50ba (patch)
tree232f2e5a3e75fac725d92ce9f276f9ea812d6567 /activerecord/lib/active_record/associations.rb
parent6e62e89737c991de712a13b67a282ce599710ec9 (diff)
downloadrails-42553a98eaa05c703de52147c870e4dd9a3d50ba.tar.gz
rails-42553a98eaa05c703de52147c870e4dd9a3d50ba.tar.bz2
rails-42553a98eaa05c703de52147c870e4dd9a3d50ba.zip
Remove find_with_associations and related code from associations now that Relation handles that stuff
Diffstat (limited to 'activerecord/lib/active_record/associations.rb')
-rwxr-xr-xactiverecord/lib/active_record/associations.rb67
1 files changed, 0 insertions, 67 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index ebf1a41e85..57785b4c93 100755
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -1463,13 +1463,6 @@ module ActiveRecord
after_destroy(method_name)
end
- def find_with_associations(options, join_dependency)
- rows = select_all_rows(options, join_dependency)
- join_dependency.instantiate(rows)
- rescue ThrowResult
- []
- end
-
# Creates before_destroy callback methods that nullify, delete or destroy
# has_many associated objects, according to the defined :dependent rule.
#
@@ -1693,66 +1686,6 @@ module ActiveRecord
reflection
end
- def select_all_rows(options, join_dependency)
- connection.select_all(
- construct_finder_sql_with_included_associations(options, join_dependency),
- "#{name} Load Including Associations"
- )
- end
-
- def construct_finder_arel_with_included_associations(options, join_dependency)
- relation = scoped
-
- for association in join_dependency.join_associations
- relation = association.join_relation(relation)
- end
-
- relation = relation.apply_finder_options(options).select(column_aliases(join_dependency))
-
- if !using_limitable_reflections?(join_dependency.reflections) && relation.limit_value
- relation = relation.where(construct_arel_limited_ids_condition(options, join_dependency))
- end
-
- relation = relation.except(:limit, :offset) unless using_limitable_reflections?(join_dependency.reflections)
-
- relation
- end
-
- def construct_finder_sql_with_included_associations(options, join_dependency)
- construct_finder_arel_with_included_associations(options, join_dependency).to_sql
- end
-
- def construct_arel_limited_ids_condition(options, join_dependency)
- if (ids_array = select_limited_ids_array(options, join_dependency)).empty?
- raise ThrowResult
- else
- Arel::Predicates::In.new(
- Arel::SqlLiteral.new("#{connection.quote_table_name table_name}.#{primary_key}"),
- ids_array
- )
- end
- end
-
- def select_limited_ids_array(options, join_dependency)
- connection.select_all(
- construct_finder_sql_for_association_limiting(options, join_dependency),
- "#{name} Load IDs For Limited Eager Loading"
- ).collect { |row| row[primary_key] }
- end
-
- def construct_finder_sql_for_association_limiting(options, join_dependency)
- relation = scoped
-
- for association in join_dependency.join_associations
- relation = association.join_relation(relation)
- end
-
- relation = relation.apply_finder_options(options).except(:select)
- relation = relation.select(connection.distinct("#{connection.quote_table_name table_name}.#{primary_key}", relation.order_values.join(", ")))
-
- relation.to_sql
- end
-
def using_limitable_reflections?(reflections)
reflections.collect(&:collection?).length.zero?
end