diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-06-23 19:40:57 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-06-23 19:40:57 -0300 |
commit | 3b27a4856f9a1a4d8f4e6d80343fcd5a80c40b35 (patch) | |
tree | 4787463dd64854ad9d305968a715ec80a183c2f7 /activerecord/lib/active_record/base.rb | |
parent | b9088dce07f8525cdb84a1312a77b81db79067d6 (diff) | |
download | rails-3b27a4856f9a1a4d8f4e6d80343fcd5a80c40b35.tar.gz rails-3b27a4856f9a1a4d8f4e6d80343fcd5a80c40b35.tar.bz2 rails-3b27a4856f9a1a4d8f4e6d80343fcd5a80c40b35.zip |
Refactoring: Calculations now use construct_finder_sql instead they own method.
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) |