mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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]
This commit is contained in:
parent
d3fd997109
commit
789a3f5b03
1 changed files with 9 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue