minor: make DB#validate_collection compatible with server v1.8 and v1.9.1
This commit is contained in:
parent
604d0f60ed
commit
f7e1feaeba
|
@ -602,7 +602,7 @@ module Mongo
|
|||
if !ok?(doc)
|
||||
raise MongoDBError, "Error with validate command: #{doc.inspect}"
|
||||
end
|
||||
if !doc['valid']
|
||||
if (doc.has_key?('valid') && !doc['valid']) || (doc['result'] =~ /\b(exception|corrupt)\b/i)
|
||||
raise MongoDBError, "Error: invalid collection #{name}: #{doc.inspect}"
|
||||
end
|
||||
doc
|
||||
|
|
|
@ -304,7 +304,11 @@ class DBTest < Test::Unit::TestCase
|
|||
|
||||
should "validate collection" do
|
||||
doc = @db.validate_collection(@coll.name)
|
||||
assert doc['valid']
|
||||
if @@version >= "1.9.1"
|
||||
assert doc['valid']
|
||||
else
|
||||
assert doc['result']
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue