[JAVA-3367] $oid does not work with min() Created: 30/Jul/19  Updated: 11/Sep/19  Resolved: 05/Aug/19

Status: Closed
Project: Java Driver
Component/s: Query Operations
Affects Version/s: 3.8.2
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Satyaprakash Reddy Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

These two queries return a different result (executed in the mongo shell):

1. This one doesn't consider _id at all. Hence returns incorrect results.

db.EntityById.find(\{'storageContainerId':'DefaultStorageContainer','bucketId':'29E31FCB56AB3E3B7F000101'})

 2. This one returns proper results.

db.EntityById.find(\{'storageContainerId':'DefaultStorageContainer','bucketId':'29E31FCB56AB3E3B7F000101'})
 .limit(5)
 .sort(\{'sortField':1, '_id':1})
 .min(\{ "sortField" : 'test', "_id" : new ObjectId("5d402ea15978f845d2218803")});

 

We're using below piece of code to generate .min() part of above query:

            
 
findIterable.min(
               *new* BsonDocument().append(sortBy,*new* BsonString(sortField))
                  .append(MongoConstants.*_ID_FIELD_*, *new* BsonObjectId(*new* ObjectId("5d402ea15978f845d2218803"))));

 

Any changes I can make to fix my code to generate _id as 'new ObjectId("<>")' in the resulting query?

We're currently blocked on this. Please help.



 Comments   
Comment by Satyaprakash Reddy [ 30/Jul/19 ]

Please close this ticket. It was an issue at my end. Sorry for the trouble.

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