Sort does not return documents sorted by natural order or _id in case of sorting by field not present in document

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Works as Designed
    • Priority: Major - P3
    • None
    • Affects Version/s: 8.0.11
    • Component/s: None
    • Server Triage
    • ALL
      1. create a empty collection in mongoDb 8 and insert attached documents json which has only _id.
      2. sort on non present field like { order: 1 }
      3. return order is messed up and random
    • None
    • 3
    • TBD
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      When using the find query with sort on a field that does not exist on any document, Previous behaviour in mongoDb 6 and 7 was it falls back to sorting by _id or maintains natural order.

      In mongoDb 8, without any sort it maintains natural order but on giving sort on a field that is not present in any document, it messes by the sorting order and gives a randomly sorted list.

        1. onlyIds.json
          1 kB
          Murugappan M

              Assignee:
              Chris Kelly
              Reporter:
              Murugappan M
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: