Skip to content
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.

select method must accept multiple arguments like in native version #339

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/squeel/adapters/active_record/relation_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@ def eager_load(*args)
end
end

def select(value = Proc.new)
if block_given? && Proc === value
if value.arity > 0 || (Squeel.sane_arity? && value.arity < 0)
to_a.select {|*block_args| value.call(*block_args)}
def select(*args, &block)
if block_given? && Proc === block
if block.arity > 0 || (Squeel.sane_arity? && block.arity < 0)
to_a.select {|*block_args| block.call(*block_args)}
else
relation = clone
relation.select_values += Array.wrap(DSL.eval &value)
relation.select_values += Array.wrap(DSL.eval &block)
relation
end
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,9 @@ module ActiveRecord
aric.last_article_id.to_i.should eq Article.where(:person_id => 1).last.id
end

it 'works with multiple arguments in select' do
Article.select("title", "body").size.should eq 31
end
end

describe '#count' do
Expand Down