From 0e0866e0565bd530ee265b9298accff4185f7022 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 21 Jul 2009 20:21:03 -0300 Subject: Introduced ActiveRecord::Relation, a layer between an ARel relation and an AR relation --- activerecord/lib/active_record/associations.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'activerecord/lib/active_record/associations.rb') diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 47f97718eb..a0aeff68b6 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1602,16 +1602,17 @@ module ActiveRecord conditions = construct_conditions(options[:conditions], scope) || '' conditions << construct_limited_ids_condition(conditions, options, join_dependency) if !using_limitable_reflections?(join_dependency.reflections) && ((scope && scope[:limit]) || options[:limit]) - arel_table((scope && scope[:from]) || options[:from]) - join(joins) - where(conditions) - project(column_aliases(join_dependency)) - group(construct_group(options[:group], options[:having], scope)) - order(construct_order(options[:order], scope)) + relation = arel_table((scope && scope[:from]) || options[:from]). + join(joins). + where(conditions). + project(column_aliases(join_dependency)). + group(construct_group(options[:group], options[:having], scope)). + order(construct_order(options[:order], scope) + ) - take(construct_limit(options[:limit], scope)) if using_limitable_reflections?(join_dependency.reflections) + relation = relation.take(construct_limit(options[:limit], scope)) if using_limitable_reflections?(join_dependency.reflections) - return sanitize_sql(arel_relation.to_sql) + return sanitize_sql(relation.to_sql) end def construct_limited_ids_condition(where, options, join_dependency) -- cgit v1.2.3