diff --git a/lib/mongo/cursor.rb b/lib/mongo/cursor.rb index dee3a79..27896c2 100644 --- a/lib/mongo/cursor.rb +++ b/lib/mongo/cursor.rb @@ -282,6 +282,8 @@ module Mongo returning({}) do |hash| fields.each { |field| hash[field] = 1 } end + when Hash + return fields end end diff --git a/test/unit/cursor_test.rb b/test/unit/cursor_test.rb index 3be5839..178d228 100644 --- a/test/unit/cursor_test.rb +++ b/test/unit/cursor_test.rb @@ -30,6 +30,13 @@ class CursorTest < Test::Unit::TestCase assert @cursor.fields == {:name => 1, :date => 1} end + should "set mix fields 0 and 1" do + assert_nil @cursor.fields + + @cursor = Cursor.new(@collection, :fields => {:name => 1, :date => 0}) + assert @cursor.fields == {:name => 1, :date => 0} + end + should "set limit" do assert_equal 0, @cursor.limit