Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-52

Undocumented distinct sorting no longer in 1.8

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Incomplete
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • None
    • None

    Description

      Apparently there was an undocumented feature of distinct in 1.6 where values would be returned binary sorted. This behavior has disappeared in 1.8.

      You could count it as a regression but I see it more of a documentation issue. IMO it'd be better to leave sorting to the client (since binary sorting might not even be the desired behavior) or something to be done explicitly. We were only bitten by this bug because nowhere in the changelog/release notes does it appear to be mentioned that this behavior changed.

      ====TEST CASE=======
      MongoDB shell version: 1.6.5
      connecting to: test
      > use test;
      switched to db test
      > db.test.insert(

      {'id':1, 'value':'blah'}

      )
      > db.test.insert(

      {'id':2, 'value':'FOO'}

      )
      > db.test.insert(

      {'id':3, 'value':'BAR'}

      )
      > db.test.insert(

      {'id':4, 'value':'bar'}

      )
      > db.test.insert(

      {'id':5, 'value':'foo'}

      )
      > db.test.distinct('value');
      [ "BAR", "FOO", "bar", "blah", "foo" ]
      >

      MongoDB shell version: 1.8.0
      connecting to: test
      > use test;
      switched to db test
      > db.test.insert(

      {'id':1, 'value':'blah'}

      )
      > db.test.insert(

      {'id':2, 'value':'FOO'}

      )
      > db.test.insert(

      {'id':3, 'value':'BAR'}

      )
      > db.test.insert(

      {'id':4, 'value':'bar'}

      )
      > db.test.insert(

      {'id':5, 'value':'foo'}

      )
      > db.test.distinct('value');
      [ "blah", "FOO", "BAR", "bar", "foo" ]
      >

      Attachments

        Activity

          People

            Unassigned Unassigned
            sirpengi shu zOMG chen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              11 years, 20 weeks, 2 days ago