diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-12-28 03:49:35 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-12-28 03:59:44 +0530 |
commit | 6a776dcc9df437c0bcc3c1ff1d2a79966264bac9 (patch) | |
tree | 46932debde94297b0e3e5e0c1dad48321b35e1cf /activerecord/lib/active_record | |
parent | 9521fcbcc295cb1dd34f7d458c40790466a55244 (diff) | |
download | rails-6a776dcc9df437c0bcc3c1ff1d2a79966264bac9.tar.gz rails-6a776dcc9df437c0bcc3c1ff1d2a79966264bac9.tar.bz2 rails-6a776dcc9df437c0bcc3c1ff1d2a79966264bac9.zip |
Use relation.from when constructing a relation
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-x | activerecord/lib/active_record/associations.rb | 5 | ||||
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 2735bc5141..c23c9f63f1 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1707,7 +1707,7 @@ module ActiveRecord def construct_finder_arel_with_included_associations(options, join_dependency) scope = scope(:find) - relation = arel_table((scope && scope[:from]) || options[:from]) + relation = arel_table for association in join_dependency.join_associations relation = association.join_relation(relation) @@ -1717,7 +1717,8 @@ module ActiveRecord select(column_aliases(join_dependency)). group(construct_group(options[:group], options[:having], scope)). order(construct_order(options[:order], scope)). - where(construct_conditions(options[:conditions], scope)) + where(construct_conditions(options[:conditions], scope)). + from((scope && scope[:from]) || options[:from]) relation = relation.where(construct_arel_limited_ids_condition(options, join_dependency)) if !using_limitable_reflections?(join_dependency.reflections) && ((scope && scope[:limit]) || options[:limit]) relation = relation.limit(construct_limit(options[:limit], scope)) if using_limitable_reflections?(join_dependency.reflections) diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index cad75f80e5..bbc5bd77c5 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1563,7 +1563,7 @@ module ActiveRecord #:nodoc: # TODO add lock to Arel validate_find_options(options) - relation = arel_table(options[:from]). + relation = arel_table. joins(construct_join(options[:joins], scope)). where(construct_conditions(options[:conditions], scope)). select(options[:select] || (scope && scope[:select]) || default_select(options[:joins] || (scope && scope[:joins]))). |