count() is 0 for non-existant collections, not an error
This commit is contained in:
parent
7b0da3cb7e
commit
c6536f0d27
|
@ -390,6 +390,7 @@ module XGen
|
|||
oh[:query] = selector || {}
|
||||
doc = db_command(oh)
|
||||
return doc['n'].to_i if ok?(doc)
|
||||
return 0 if doc['errmsg'] == "ns missing"
|
||||
raise "Error with count command: #{doc.inspect}"
|
||||
end
|
||||
|
||||
|
|
|
@ -56,6 +56,11 @@ class DBAPITest < Test::Unit::TestCase
|
|||
assert docs.detect { |row| row['b'] == 3 }
|
||||
end
|
||||
|
||||
def test_count_on_nonexisting
|
||||
@@db.drop_collection('foo')
|
||||
assert_equal 0, @@db.collection('foo').count()
|
||||
end
|
||||
|
||||
def test_find_simple
|
||||
@r2 = @@coll.insert('a' => 2)
|
||||
@r3 = @@coll.insert('b' => 3)
|
||||
|
|
Loading…
Reference in New Issue