diff options
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 2453d38aca..c7fc1fa124 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1696,11 +1696,9 @@ module ActiveRecord #:nodoc: @arel_table = Arel::Table.new(table) end - def construct_finder_arel(options) - scope = scope(:find) - + def construct_finder_arel(options, scope = scope(:find)) # TODO add lock to Arel - arel_table(table_name). + arel_table(options[:from] || table_name). join(construct_join(options[:joins], scope)). where(construct_conditions(options[:conditions], scope)). project(options[:select] || (scope && scope[:select]) || default_select(options[:joins] || (scope && scope[:joins]))). @@ -1711,8 +1709,8 @@ module ActiveRecord #:nodoc: ) end - def construct_finder_sql(options) - construct_finder_arel(options).to_sql + def construct_finder_sql(options, scope = scope(:find)) + construct_finder_arel(options, scope).to_sql end def construct_join(joins, scope) |