aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations.rb
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-07-21 20:21:03 -0300
committerEmilio Tagua <miloops@gmail.com>2009-07-21 20:21:03 -0300
commit0e0866e0565bd530ee265b9298accff4185f7022 (patch)
tree80bb65ebb7567999ca3de72cec47fc31fd2e3969 /activerecord/lib/active_record/associations.rb
parentf32c3709830eb8d9f68a59c94f6791621c2b52ac (diff)
downloadrails-0e0866e0565bd530ee265b9298accff4185f7022.tar.gz
rails-0e0866e0565bd530ee265b9298accff4185f7022.tar.bz2
rails-0e0866e0565bd530ee265b9298accff4185f7022.zip
Introduced ActiveRecord::Relation, a layer between an ARel relation and an AR relation
Diffstat (limited to 'activerecord/lib/active_record/associations.rb')
-rwxr-xr-xactiverecord/lib/active_record/associations.rb17
1 files changed, 9 insertions, 8 deletions
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)