[SERVER-10805] Numbers returned from 2.4.5 database are Doubles that were Integers in 2.4.4 Created: 17/Sep/13  Updated: 10/Dec/14  Resolved: 12/Dec/13

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 2.4.5
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Jay Cliffe Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

unknown linux


Backwards Compatibility: Major Change
Operating System: ALL
Steps To Reproduce:
  • save a document with a field value of 1 (the number, not the string) to each database (2.4.4 & 2.4.5)
  • retrieve that using the Java driver 2.11.2 and call .toString() on that field value without any casting or assigning.
Participants:

 Description   

Using java driver 2.11.2 to connect to two different mongo instances with the same data in them (written by our client app w/ 2.11.2) and retrieve a document, the following returns different values:

dbObject.get("someNumber").toString()

2.4.4:
"1"

2.4.5:
"1.0"

Nothing else was upgraded or changed, but this is obviously a breaking change to the behavior or some client applications.

I could not find any indication that this would happen in the 2.4 documentation.



 Comments   
Comment by Matt Kangas [ 02/Oct/13 ]

Hello Jay. Are you still facing the problem described above? If so, it would greatly help us if you post your test case. If not, please mark this ticket as resolved.

If you happened to save a value from the mongo shell as an integer literal to mongodb (neither quoted nor using the NumberInt() constructor), then retrieve that value using the Java driver, you will see the behavior you describe above. This is because Javascript doesn't have a native integer type and silently converts it to a floating point value.

http://docs.mongodb.org/manual/core/shell-types/#numberint

Comment by Matt Kangas [ 18/Sep/13 ]

Hi jcliffe - can you post the test case you used to identify this issue? We will immediately try to reproduce the behavior you're seeing, but it would be exceptionally helpful to see your code which illustrates this issue too.

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