Skip to content

Commit

Permalink
Revert "allow select to have multiple arguments"
Browse files Browse the repository at this point in the history
This reverts commit 04cc446.

I reverted it because apparently we want to use: select([:a, :b])
instead of select(:a, :b), but there was no tests for that form.
  • Loading branch information
drogus authored and fxn committed Aug 13, 2011
1 parent e7f7439 commit 182a428
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
9 changes: 3 additions & 6 deletions activerecord/lib/active_record/relation/query_methods.rb
Expand Up @@ -37,15 +37,12 @@ def preload(*args)
relation
end

def select(*args, &blk)
if !block_given? && args.blank?
raise ArgumentError
end
def select(value = Proc.new)
if block_given?
to_a.select {|*block_args| blk.call(*block_args) }
to_a.select {|*block_args| value.call(*block_args) }
else
relation = clone
relation.select_values += args
relation.select_values += Array.wrap(value)
relation
end
end
Expand Down
5 changes: 0 additions & 5 deletions activerecord/test/cases/base_test.rb
Expand Up @@ -123,11 +123,6 @@ def test_select_symbol
assert_equal Topic.all.map(&:id).sort, topic_ids
end

def test_select_symbol_for_many_arguments
topics = Topic.select(:id, :author_name).map{|topic| [topic.id, topic.author_name]}.sort
assert_equal Topic.all.map{|topic| [topic.id,topic.author_name]}.sort, topics
end

def test_table_exists
assert !NonExistentTable.table_exists?
assert Topic.table_exists?
Expand Down

0 comments on commit 182a428

Please sign in to comment.