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 || {}
|
oh[:query] = selector || {}
|
||||||
doc = db_command(oh)
|
doc = db_command(oh)
|
||||||
return doc['n'].to_i if ok?(doc)
|
return doc['n'].to_i if ok?(doc)
|
||||||
|
return 0 if doc['errmsg'] == "ns missing"
|
||||||
raise "Error with count command: #{doc.inspect}"
|
raise "Error with count command: #{doc.inspect}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,11 @@ class DBAPITest < Test::Unit::TestCase
|
||||||
assert docs.detect { |row| row['b'] == 3 }
|
assert docs.detect { |row| row['b'] == 3 }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_count_on_nonexisting
|
||||||
|
@@db.drop_collection('foo')
|
||||||
|
assert_equal 0, @@db.collection('foo').count()
|
||||||
|
end
|
||||||
|
|
||||||
def test_find_simple
|
def test_find_simple
|
||||||
@r2 = @@coll.insert('a' => 2)
|
@r2 = @@coll.insert('a' => 2)
|
||||||
@r3 = @@coll.insert('b' => 3)
|
@r3 = @@coll.insert('b' => 3)
|
||||||
|
|
Loading…
Reference in New Issue