From 30dd944c47d84482880387ce82bbebe65a79ed9f Mon Sep 17 00:00:00 2001 From: Mathias Stearn Date: Tue, 29 Mar 2011 20:20:04 -0400 Subject: validate command now puts all data in proper fields SERVER-2849 --- shell/collection.js | 22 +++++++++++++--------- shell/mongo_vstudio.cpp | 4 ++++ 2 files changed, 17 insertions(+), 9 deletions(-) (limited to 'shell') diff --git a/shell/collection.js b/shell/collection.js index 350276f1cb0..eb47a48dd1b 100644 --- a/shell/collection.js +++ b/shell/collection.js @@ -384,18 +384,22 @@ DBCollection.prototype.validate = function(full) { var res = this._db.runCommand( cmd ); - res.valid = false; + if (typeof(res.valid) == undefined) { + // old-style format just put everything in a string. Now using proper fields - var raw = res.result || res.raw; + res.valid = false; - if ( raw ){ - var str = "-" + tojson( raw ); - res.valid = ! ( str.match( /exception/ ) || str.match( /corrupt/ ) ); + var raw = res.result || res.raw; - var p = /lastExtentSize:(\d+)/; - var r = p.exec( str ); - if ( r ){ - res.lastExtentSize = Number( r[1] ); + if ( raw ){ + var str = "-" + tojson( raw ); + res.valid = ! ( str.match( /exception/ ) || str.match( /corrupt/ ) ); + + var p = /lastExtentSize:(\d+)/; + var r = p.exec( str ); + if ( r ){ + res.lastExtentSize = Number( r[1] ); + } } } diff --git a/shell/mongo_vstudio.cpp b/shell/mongo_vstudio.cpp index 6848a96f57e..7947f81ca45 100644 --- a/shell/mongo_vstudio.cpp +++ b/shell/mongo_vstudio.cpp @@ -3185,6 +3185,9 @@ const StringData _jscode_raw_collection = "\n" "var res = this._db.runCommand( cmd );\n" "\n" +"if (typeof(res.valid) == undefined) {\n" +"// old-style format just put everything in a string. Now using proper fields\n" +"\n" "res.valid = false;\n" "\n" "var raw = res.result || res.raw;\n" @@ -3199,6 +3202,7 @@ const StringData _jscode_raw_collection = "res.lastExtentSize = Number( r[1] );\n" "}\n" "}\n" +"}\n" "\n" "return res;\n" "}\n" -- cgit v1.2.1