[SERVER-27852] CLI formatter for doubles should emit {value}.0 for doubles with no fractional component Created: 29/Jan/17  Updated: 06/Dec/22

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

Type: Improvement Priority: Major - P3
Reporter: Buzz Moschetti Assignee: Backlog - Server Tooling and Methods (STM) (Inactive)
Resolution: Unresolved Votes: 0
Labels: move-sa, move-stm, platforms-re-triaged
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Server Tooling & Methods
Participants:

 Description   

A common thing to do in the CLI is this:

> db.foo.findOne();
{
	"_id" : ObjectId("588d3099827f74e88834ba88"),
	"K_dbl" : 3,
...

and then copy and paste the output somewhere. As the field name hints here, K_dbl is double:

Buzzs-MacBook-Pro-2:stuff buzz$ sh runt walkMongo -d testX -c foo --justOne
_id: org.bson.types.ObjectId: 588d3099827f74e88834ba88
K_dbl: java.lang.Double: 3.0
...

We really should add ".0" to make it totally obvious this is a double.



 Comments   
Comment by Jonathan Reams [ 01/Feb/17 ]

I'm not sure this is really doable or desirable. In javascript all numbers are doubles unless they're one of our custom NumberInt or NumberLong types. I'd prefer not to make javascript numbers into a custom type - especially since "3" is just as valid a double as "3.0". Is there something about copying and pasting "3" instead of "3.0" that causes an error in another language?

Comment by Asya Kamsky [ 31/Jan/17 ]

is the issue that we don't show that it's a float (all numbers in JS are floats) or that we would show NumberInt the exact same way?

Generated at Thu Feb 08 04:16:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.