aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations.rb
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-08-18 07:50:11 -0300
committerEmilio Tagua <miloops@gmail.com>2009-08-18 07:50:11 -0300
commit79e951ca9bc875da9e4a19adeff3634f0b5b7b76 (patch)
tree3b46a3061cea3bc6a1d7a72d9e6f5c793a56663b /activerecord/lib/active_record/associations.rb
parentc923409630a92d1a935699c1427702c822601165 (diff)
downloadrails-79e951ca9bc875da9e4a19adeff3634f0b5b7b76.tar.gz
rails-79e951ca9bc875da9e4a19adeff3634f0b5b7b76.tar.bz2
rails-79e951ca9bc875da9e4a19adeff3634f0b5b7b76.zip
Use finder options as relation method names to provide more familiar
naming. Use bang methods convention in methods that alter the relation.
Diffstat (limited to 'activerecord/lib/active_record/associations.rb')
-rwxr-xr-xactiverecord/lib/active_record/associations.rb34
1 files changed, 17 insertions, 17 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index 406f08e247..d0322280d9 100755
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -1681,15 +1681,15 @@ module ActiveRecord
for association in join_dependency.join_associations
relation = association.join_relation(relation)
end
- relation.join(construct_join(options[:joins], scope))
- relation.where(construct_conditions(options[:conditions], scope))
- relation.where(construct_arel_limited_ids_condition(options, join_dependency)) if !using_limitable_reflections?(join_dependency.reflections) && ((scope && scope[:limit]) || options[:limit])
+ relation.joins!(construct_join(options[:joins], scope)).
+ select!(column_aliases(join_dependency)).
+ group!(construct_group(options[:group], options[:having], scope)).
+ order!(construct_order(options[:order], scope)).
+ conditions!(construct_conditions(options[:conditions], scope))
- relation.project(column_aliases(join_dependency))
- relation.group(construct_group(options[:group], options[:having], scope))
- relation.order(construct_order(options[:order], scope))
- relation.take(construct_limit(options[:limit], scope)) if using_limitable_reflections?(join_dependency.reflections)
+ relation.conditions!(construct_arel_limited_ids_condition(options, join_dependency)) if !using_limitable_reflections?(join_dependency.reflections) && ((scope && scope[:limit]) || options[:limit])
+ relation.limit!(construct_limit(options[:limit], scope)) if using_limitable_reflections?(join_dependency.reflections)
relation
end
@@ -1724,15 +1724,15 @@ module ActiveRecord
for association in join_dependency.join_associations
relation = association.join_relation(relation)
end
- relation.join(construct_join(options[:joins], scope))
- relation.where(construct_conditions(options[:conditions], scope))
- relation.project(connection.distinct("#{connection.quote_table_name table_name}.#{primary_key}", construct_order(options[:order], scope(:find)).join(",")))
+ relation.joins!(construct_join(options[:joins], scope)).
+ conditions!(construct_conditions(options[:conditions], scope)).
+ group!(construct_group(options[:group], options[:having], scope)).
+ order!(construct_order(options[:order], scope)).
+ limit!(construct_limit(options[:limit], scope)).
+ offset!(construct_limit(options[:offset], scope))
- relation.group(construct_group(options[:group], options[:having], scope))
- relation.order(construct_order(options[:order], scope))
- relation.take(construct_limit(options[:limit], scope))
- relation.skip(construct_limit(options[:offset], scope))
+ relation.select!(connection.distinct("#{connection.quote_table_name table_name}.#{primary_key}", construct_order(options[:order], scope(:find)).join(",")))
sanitize_sql(relation.to_sql)
end
@@ -2222,10 +2222,10 @@ module ActiveRecord
def join_relation(joining_relation, join = nil)
if relation.is_a?(Array)
- joining_relation.join(relation.first, join_type).on(association_join.first)
- joining_relation.join(relation.last, join_type).on(association_join.last)
+ joining_relation.joins!(relation.first, join_type).on!(association_join.first)
+ joining_relation.joins!(relation.last, join_type).on!(association_join.last)
else
- joining_relation.join(relation, join_type).on(association_join)
+ joining_relation.joins!(relation, join_type).on!(association_join)
end
joining_relation
end