Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

select should raise error when no block or no parameter is passed

  • Loading branch information...
commit d73fcfeb520c77a859c5be61642f138da0290102 1 parent b8899bb
@tenderlove tenderlove authored
View
6 activerecord/lib/active_record/relation/query_methods.rb
@@ -29,12 +29,12 @@ def preload(*args)
relation
end
- def select(value = nil)
+ def select(value = Proc.new)
if block_given?
- to_a.select {|*block_args| yield(*block_args) }
+ to_a.select {|*block_args| value.call(*block_args) }
else
relation = clone
- relation.select_values += [value] if value
+ relation.select_values += [value]
relation
end
end
View
4 activerecord/test/cases/relations_test.rb
@@ -465,6 +465,10 @@ def test_delete_all_loaded
assert davids.loaded?
end
+ def test_select_argument_error
+ assert_raises(ArgumentError) { Developer.select }
+ end
+
def test_relation_merging
devs = Developer.where("salary >= 80000") & Developer.limit(2) & Developer.order('id ASC').where("id < 3")
assert_equal [developers(:david), developers(:jamis)], devs.to_a
Please sign in to comment.
Something went wrong with that request. Please try again.