aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorWill Bryant <will.bryant@gmail.com>2008-11-14 11:04:53 +1300
committerMichael Koziarski <michael@koziarski.com>2008-11-15 18:26:41 +0100
commit789a3f5b035fd293a9e235672a97b683a56ba0c3 (patch)
tree9ef458315e6a3b516578797fe90db049664e1fe6 /activerecord
parentd3fd9971093101712e4cc97ccc534631888b673d (diff)
downloadrails-789a3f5b035fd293a9e235672a97b683a56ba0c3.tar.gz
rails-789a3f5b035fd293a9e235672a97b683a56ba0c3.tar.bz2
rails-789a3f5b035fd293a9e235672a97b683a56ba0c3.zip
Moved the * strings out of construct_finder_sql to a new default_select method so it can be overridden by plugins cleanly
Signed-off-by: Michael Koziarski <michael@koziarski.com> [#1371 state:resolved]
Diffstat (limited to 'activerecord')
-rwxr-xr-xactiverecord/lib/active_record/base.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 757102eb6b..dcc8277849 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1612,9 +1612,17 @@ module ActiveRecord #:nodoc:
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)