@@ -326,7 +326,7 @@ def last_status
326326 #
327327 # @return [Boolean]
328328 def error?
329- error != nil
329+ get_last_error [ 'err' ] != nil
330330 end
331331
332332 # Get the most recent error to have occured on this database.
@@ -379,10 +379,9 @@ def eval(code, *args)
379379
380380 oh = BSON ::OrderedHash . new
381381 oh [ :$eval ] = code
382- oh [ :args ] = args
382+ oh [ :args ] = args
383383 doc = command ( oh )
384- return doc [ 'retval' ] if ok? ( doc )
385- raise OperationFailure , "eval failed: #{ doc [ 'errmsg' ] } "
384+ doc [ 'retval' ]
386385 end
387386
388387 # Rename a collection.
@@ -397,7 +396,7 @@ def rename_collection(from, to)
397396 oh = BSON ::OrderedHash . new
398397 oh [ :renameCollection ] = "#{ @name } .#{ from } "
399398 oh [ :to ] = "#{ @name } .#{ to } "
400- doc = DB . new ( 'admin' , @connection ) . command ( oh )
399+ doc = DB . new ( 'admin' , @connection ) . command ( oh , :check_response => false )
401400 ok? ( doc ) || raise ( MongoDBError , "Error renaming collection: #{ doc . inspect } " )
402401 end
403402
@@ -434,7 +433,6 @@ def index_information(collection_name)
434433 info
435434 end
436435
437-
438436 # Return stats on this database. Uses MongoDB's dbstats command.
439437 #
440438 # @return [Hash]
@@ -530,7 +528,7 @@ def pk_factory=(pk_factory)
530528 def profiling_level
531529 oh = BSON ::OrderedHash . new
532530 oh [ :profile ] = -1
533- doc = command ( oh )
531+ doc = command ( oh , :check_response => false )
534532 raise "Error with profile command: #{ doc . inspect } " unless ok? ( doc ) && doc [ 'was' ] . kind_of? ( Numeric )
535533 case doc [ 'was' ] . to_i
536534 when 0
@@ -560,7 +558,7 @@ def profiling_level=(level)
560558 else
561559 raise "Error: illegal profiling level value #{ level } "
562560 end
563- doc = command ( oh )
561+ doc = command ( oh , :check_response => false )
564562 ok? ( doc ) || raise ( MongoDBError , "Error with profile command: #{ doc . inspect } " )
565563 end
566564
@@ -580,7 +578,7 @@ def profiling_info
580578 # @raise [MongoDBError] if the command fails or there's a problem with the validation
581579 # data, or if the collection is invalid.
582580 def validate_collection ( name )
583- doc = command ( :validate => name )
581+ doc = command ( { :validate => name } , :check_response => false )
584582 raise MongoDBError , "Error with validate command: #{ doc . inspect } " unless ok? ( doc )
585583 result = doc [ 'result' ]
586584 raise MongoDBError , "Error with validation data: #{ doc . inspect } " unless result . kind_of? ( String )
0 commit comments