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

distinct on a view doesn't "flatten" array members

    XMLWordPrintable

    Details

    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Completed:
    • Backport Requested:
      v3.4
    • Sprint:
      Query 2017-02-13

      Description

      If you create an identity view on a collection which has some field that contains an array, the result of db.collection.distinct("thatfield") and db.identityview.distinct("thatfield") will not be the same.

      db.coll.find()
      { "_id" : ObjectId("5876aaed34e6e16cd498d61c"), "a" : 1 }
      { "_id" : ObjectId("5876aaf034e6e16cd498d61d"), "a" : [ 2 ] }
      { "_id" : ObjectId("5876aaf734e6e16cd498d61e"), "a" : [ 3, 4 ] }
      db.coll.distinct("a")
      [ 1, 2, 3, 4 ]
      db.createView("view","coll",[])
      { "ok" : 1 }
      agg@127.0.0.1:27017(3.4.1) > db.view.distinct("a")
      [ [ 3, 4 ], [ 2 ], 1 ]
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: