Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-3367

$oid does not work with min()

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Done
    • Affects Version/s: 3.8.2
    • Fix Version/s: None
    • Component/s: Query Operations
    • Labels:
      None

      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.

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            satyaprakash1729@gmail.com Satyaprakash Reddy
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: