if fields is [] return just _id
This commit is contained in:
parent
dcda70fddd
commit
e64b7f3679
|
@ -85,7 +85,7 @@ module XGen
|
||||||
# http://www.mongodb.org/display/DOCS/How+to+do+Snapshotting+in+the+Mongo+Database
|
# http://www.mongodb.org/display/DOCS/How+to+do+Snapshotting+in+the+Mongo+Database
|
||||||
def find(selector={}, options={})
|
def find(selector={}, options={})
|
||||||
fields = options.delete(:fields)
|
fields = options.delete(:fields)
|
||||||
fields = nil if fields && fields.empty?
|
fields = ["_id"] if fields && fields.empty?
|
||||||
offset = options.delete(:offset) || 0
|
offset = options.delete(:offset) || 0
|
||||||
limit = options.delete(:limit) || 0
|
limit = options.delete(:limit) || 0
|
||||||
sort = options.delete(:sort)
|
sort = options.delete(:sort)
|
||||||
|
|
|
@ -124,6 +124,7 @@ class TestCollection < Test::Unit::TestCase
|
||||||
|
|
||||||
assert @@test.find_one(nil, :fields => ["hello"]).include?("hello")
|
assert @@test.find_one(nil, :fields => ["hello"]).include?("hello")
|
||||||
assert !@@test.find_one(nil, :fields => ["foo"]).include?("hello")
|
assert !@@test.find_one(nil, :fields => ["foo"]).include?("hello")
|
||||||
|
assert_equal ["_id"], @@test.find_one(nil, :fields => []).keys()
|
||||||
|
|
||||||
assert_equal nil, @@test.find_one("hello" => "foo")
|
assert_equal nil, @@test.find_one("hello" => "foo")
|
||||||
assert_equal nil, @@test.find_one(OrderedHash["hello", "foo"])
|
assert_equal nil, @@test.find_one(OrderedHash["hello", "foo"])
|
||||||
|
|
Loading…
Reference in New Issue