Thanks to a pointer from Stefan Kaes, I updated my local Rails
installation to include the :select option (from the current trunk):
def construct_finder_sql(options) # in active_record/base.rb
sql = "SELECT #{options[:select] || ''*''} FROM
#{table_name} "
sql << " #{options[:joins]} " if options[:joins]
add_conditions!(sql, options[:conditions])
sql << "ORDER BY #{options[:order]} " if options[:order]
add_limit!(sql, options)
sql
end
Works great, but there''s no way to define an alias for the main
table_name itself. Here''s how I think it could be implemented:
sql = "SELECT #{options[:select] || ''*''} FROM "
sql << "#{table_name} #{options[:alias] ||
''''}"
What do you folks think about this? I know it would be unpractical to
try to implement every single select option in find(), but I think this
qualifies as a significant complement to the :select option.
Has anyone suggested this already? Should I open a ticket?
--Jonas Galvez