From bef7c35c94fa1e39b3796a1b9e9ec29fac83d292 Mon Sep 17 00:00:00 2001 From: Will Bryant Date: Fri, 14 Nov 2008 11:04:53 +1300 Subject: [PATCH] moved the * strings out of construct_finder_sql to a new default_select method so it can be overridden by plugins cleanly --- activerecord/lib/active_record/base.rb | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 757102e..4a227b0 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1611,10 +1611,18 @@ module ActiveRecord #:nodoc: (/^::/ =~ type_name) ? type_name : "#{parent.name}::#{type_name}" end end + + def default_select(qualified) + if qualified + quoted_table_name + '.*' + else + '*' + end + end def construct_finder_sql(options) scope = scope(:find) - sql = "SELECT #{options[:select] || (scope && scope[:select]) || ((options[:joins] || (scope && scope[:joins])) && quoted_table_name + '.*') || '*'} " + sql = "SELECT #{options[:select] || (scope && scope[:select]) || default_select(options[:joins] || (scope && scope[:joins]))} " sql << "FROM #{(scope && scope[:from]) || options[:from] || quoted_table_name} " add_joins!(sql, options[:joins], scope) -- 1.5.5.1