-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 1.4.2
-
Component/s: None
-
None
The following command
database.RunCommand("repairDatabase")
throws the exception:
Message=Command 'repairDatabase' failed: bad option (response:
{ "errmsg" : "bad option", "ok" : 0.0 })
Source=MongoDB.Driver
StackTrace:
at MongoDB.Driver.MongoDatabase.RunCommandAs(Type commandResultType, IMongoCommand command) in C:\Active\mongo-csharp-driver\Driver\Core\MongoDatabase.cs:line 981
at MongoDB.Driver.MongoDatabase.RunCommandAs(Type commandResultType, String commandName) in C:\Active\mongo-csharp-driver\Driver\Core\MongoDatabase.cs:line 995
at MongoDB.Driver.MongoDatabase.RunCommandAs[TCommandResult](String commandName) in C:\Active\mongo-csharp-driver\Driver\Core\MongoDatabase.cs:line 954
at MongoDB.Driver.MongoDatabase.RunCommand(String commandName) in C:\Active\mongo-csharp-driver\Driver\Core\MongoDatabase.cs:line 930
at Program.Main(String[] args) in c:\ROM\DEV\TryMongo\Program.cs:line 16
Just a guess. If I use `1` instead of `true` in the C# driver code below then the command works.
MongoDatabase.RunCommandAs(Type commandResultType, string commandName)
Driver\Core\MongoDatabase.cs(994):
var command = new CommandDocument(commandName, true); // guess: perhaps `1` should be used, not `true`
At least, if we take a look at the definition of runCommand in the shell then we see that 1 is used:
> db.runCommand
function (obj) {
if (typeof obj == "string") {
var n = {};
n[obj] = 1;
obj = n;
}
return this.getCollection("$cmd").findOne(obj);
}
The full program code (very trivial) is attached.