Skip to content

Commit

Permalink
Fix simple find with multiple values for a single index
Browse files Browse the repository at this point in the history
  • Loading branch information
Matías Flores authored and soveran committed Jul 2, 2010
1 parent 872c3a9 commit c4d1dd2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/ohm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,9 @@ def inspect

class Index < Set
def apply(operation, hash, glue)
if hash.keys.size == 1
return Set.new(keys(hash).first, Wrapper.wrap(model))
keys = keys(hash)
if keys.size == 1
return Set.new(keys.first, Wrapper.wrap(model))
else
super
end
Expand Down
2 changes: 2 additions & 0 deletions test/indices_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,11 @@ def days
@event1 = Event.create(:timeline => 1).update(:days => [1, 2])
@event2 = Event.create(:timeline => 1).update(:days => [2, 3])
@event3 = Event.create(:timeline => 2).update(:days => [3, 4])
@event4 = Event.create(:timeline => 2).update(:days => [1, 3])
end

should "intersect multiple sets of results" do
assert_equal [@event1], Event.find(:days => [1, 2]).all
assert_equal [@event1], Event.find(:timeline => 1, :days => [1, 2]).all
assert_equal [@event1], Event.find(:timeline => 1).find(:days => [1, 2]).all
end
Expand Down

0 comments on commit c4d1dd2

Please sign in to comment.