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

Sorting on multiple keys when one is _id (when String) fails

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.3.3
    • Component/s: Querying
    • Labels:
      None
    • Environment:
      Mac OS

      Discovered to day that a sort on multiple fields fails when one is _id. In this case, I'm using a String as my _id, so it's relevant to sort on this field. Sorting just on _id or another fields works, but if I sort by another field and then _id, only _id sorting is performed. I compared with a multi-field sort not using _id (in this case "level" and "value_type") and this worked as expected: sorting occurred by level and then by value_type.

      Sorts only by _id:
      db.foo.find().sort(

      { some_key: 1, _id: 1}

      )

      Sorts properly by both keys:
      db.foo.find().sort(

      { some_key: 1, another_key: 1}

      )

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            jamieorc Jamie Orchard-Hays
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: