[JAVA-1307] Query operate issue Created: 07/Jul/14  Updated: 07/Jul/14  Resolved: 07/Jul/14

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: 2.12.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Dong [X] Assignee: Ross Lawley
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

I use Mongodb 2.6.1.
Reproduce steps:
1. used Mongdb command db.test.insert({item:'a',qty:12}) to create a document.
2. use command `db.test.aggregate({$match:{qty:12}})` to query document, the result is:

{ "_id" : ObjectId("53b9fcd6a50ca592c6e34b34"), "item" : "a", "qty" : 12 }

3. use java api function “dbCollection.aggregate(args…)” to query document, the result is

{ "_id" : { "$oid" : "53b9fcd6a50ca592c6e34b34"} , "item" : "a" , "qty" : 12.0}

As the result from step 2 and step 3, the field "qty" value is different.
The java api result should not have ".0".



 Comments   
Comment by Ross Lawley [ 07/Jul/14 ]

Hi Dong,

The Java driver is correct and returning a Double value for qty as that is how it was originally stored. The confusion is caused by how the mongo shell represents numbers. If you specifically need an Integer then in the shell you need to use NumberInt(12).

See the shell types documentation for more information.

Ross

Comment by Dong [X] [ 07/Jul/14 ]

Java driver 2.12.2 also have this issue.

Generated at Thu Feb 08 08:54:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.