Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Moved the * strings out of construct_finder_sql to a new default_sele…
…ct method so it can be overridden by plugins cleanly

Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#1371 state:resolved]
  • Loading branch information
willbryant authored and NZKoz committed Nov 15, 2008
1 parent d3fd997 commit 789a3f5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion activerecord/lib/active_record/base.rb
Expand Up @@ -1612,9 +1612,17 @@ def type_name_with_module(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)
Expand Down

0 comments on commit 789a3f5

Please sign in to comment.