Ticket #5863: select_accepts_array.patch
| File select_accepts_array.patch, 1.6 kB (added by veader, 5 months ago) |
|---|
-
test/cases/base_test.rb
old new 1839 1839 assert_equal %(#<Topic id: 1>), Topic.find(:first, :select => 'id', :conditions => 'id = 1').inspect 1840 1840 assert_equal %(#<Topic id: 1, title: "The First Topic">), Topic.find(:first, :select => 'id, title', :conditions => 'id = 1').inspect 1841 1841 end 1842 1843 def test_inspect_limited_select_instance_with_array 1844 assert_equal %(#<Topic id: 1, title: "The First Topic">), Topic.find(:first, :select => [:id, :title], :conditions => 'id = 1').inspect 1845 end 1842 1846 1843 1847 def test_inspect_class_without_table 1844 1848 assert_equal "NonExistentTable(Table doesn't exist)", NonExistentTable.inspect -
lib/active_record/base.rb
old new 1365 1365 1366 1366 def construct_finder_sql(options) 1367 1367 scope = scope(:find) 1368 sql = "SELECT #{(scope && scope[:select]) || options[:select] || (options[:joins] && quoted_table_name + '.*') || '*'} " 1368 select_items = (scope && scope[:select]) || options[:select] 1369 select_items = select_items.join(',') if select_items && select_items.respond_to?(:join) 1370 sql = "SELECT #{select_items || (options[:joins] && quoted_table_name + '.*') || '*'} " 1369 1371 sql << "FROM #{(scope && scope[:from]) || options[:from] || quoted_table_name} " 1370 1372 1371 1373 add_joins!(sql, options, scope)