Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-30392

Query does not return a document when the sub-document fields are not listed in the same order as they exist in the document

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • 3.2.16
    • Querying
    • None
    • ALL
    • Hide

      As provided in description. I have tested this in MongoDB 3.2

      Show
      As provided in description. I have tested this in MongoDB 3.2

    Description

      Assume the collection name "groups"

      Sample Document:

      {
          "_id" : ObjectId("597620fcba76f211586c9203"),
          "task" : {
              "taskId" : ObjectId("597620fcba76f211586c9402"),
              "hasTasks" : true
          }
      }
      

      Failing Query:

      db.getCollection('groups').find({task: { hasTasks: true, taskId: ObjectId("597620fcba76f211586c9402")}, _id: ObjectId("597620fcba76f211586c9203") })
      
      

      Passing Query:

      db.getCollection('groups').find({task: { taskId: ObjectId("597620fcba76f211586c9402"), hasTasks: true, }, _id: ObjectId("597620fcba76f211586c9203") })
      
      

      As you can see, if the order of the query fields in the sub-document (viz. task) does not match the order in which it exists in the document, query does not return any results.

      Attachments

        Activity

          People

            mark.agarunov Mark Agarunov
            catchshyam Shyam Prakash RK
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: