diff --git a/lib/mongo/db.rb b/lib/mongo/db.rb index 57a36f0..601bfa5 100644 --- a/lib/mongo/db.rb +++ b/lib/mongo/db.rb @@ -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 diff --git a/test/db_test.rb b/test/db_test.rb index 891dbbd..6445e44 100644 --- a/test/db_test.rb +++ b/test/db_test.rb @@ -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