[SERVER-15546] Command response "ok" value is floating point, should be bool or int Created: 07/Oct/14  Updated: 09/Apr/20

Status: Open
Project: Core Server
Component/s: Usability
Affects Version/s: None
Fix Version/s: features we're not sure of

Type: Improvement Priority: Minor - P4
Reporter: Danielle Jenkins Assignee: DO NOT USE - Backlog - Platform Team
Resolution: Unresolved Votes: 0
Labels: move-sa, polish
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

Expected Result:
The statement db.command("collStats", "c") should return ints for all numeric keys.

Actual Result:
The statement db.command("collStats", "c") returns "1.0" for the key "ok" and "1.0" for the key "paddingFactor". This does not match the docs http://docs.mongodb.org/manual/reference/command/collStats/.



 Comments   
Comment by Matt Kangas [ 08/Oct/14 ]

The "ok:" floating point value appears to come from Command::appendCommandStatus()
https://github.com/mongodb/mongo/blame/r2.7.7/src/mongo/db/commands.cpp#L239-L240

This seems unfortunate, but for backwards compatibility reasons we may not be able to correct this easily.

paddingFactor is defined as a double in the server, so a floating point representation is correct.

Comment by Matt Kangas [ 08/Oct/14 ]

I can repro on MongoDB 2.6.1

Shell:

> db.version()
2.6.1
> db.runCommand({"collstats":"test"})
{
	"ns" : "test.test",
	"count" : 2,
	"size" : 96,
	"avgObjSize" : 48,
	"storageSize" : 8192,
	"numExtents" : 1,
	"nindexes" : 1,
	"lastExtentSize" : 8192,
	"paddingFactor" : 1,
	"systemFlags" : 1,
	"userFlags" : 1,
	"totalIndexSize" : 8176,
	"indexSizes" : {
		"_id_" : 8176
	},
	"ok" : 1
}

pymongo:

>>> db.command("collStats","test")
{u'count': 2, u'ns': u'test.test', u'ok': 1.0, u'lastExtentSize': 8192, u'avgObjSize': 48, u'totalIndexSize': 8176, u'systemFlags': 1, u'userFlags': 1, u'numExtents': 1, u'nindexes': 1, u'storageSize': 8192, u'indexSizes': {u'_id_': 8176}, u'paddingFactor': 1.0, u'size': 96}

Comment by Bernie Hackett [ 07/Oct/14 ]

Hi,

I've moved this to the SERVER project because the python driver just decodes the types defined in the response. If the response defines these fields as BSON int32 the python driver will return python int. If the response defines the fields as BSON double, the python driver returns a python float. It does not change the type defined in the response from the server.

Generated at Thu Feb 08 03:38:20 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.