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

Inconsistent handling of arrays as $group keys

    XMLWordPrintable

Details

    • Minor Change
    • ALL
    • Query 2019-09-23, Query 2019-10-07

    Description

      > db.foo.find()
      { "_id" : 2 }
      { "_id" : 1, "x" : null }
      { "_id" : 3, "y" : null }
      { "_id" : 4, "x" : null, "y" : null }
      > db.foo.aggregate([{$group: {_id: ["$x", "$y"]}}])
      { "_id" : [ "$x", "$y" ] }
      > db.foo.aggregate([{$group: {_id: {z: ["$x", "$y"]}}}])
      { "_id" : { "z" : [ null, null ] } }
      

      I would contend that the middle one should result in

      {_id: [null, null]}
      

      Looks like this is the offending line.

      Attachments

        Activity

          People

            ted.tuckman@mongodb.com Ted Tuckman
            charlie.swanson@mongodb.com Charlie Swanson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: