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

Aggregation $project generates new array fields differently than new non-array fields

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 3.1.8
    • Aggregation Framework
    • None
    • Fully Compatible
    • ALL

    Description

      This aggregation, when aaaa and bbbb are both non-existent fields generates inconsistent result:

      db.foo.aggregate({$project:{aaaa:"$aaaa", bbbb: [ "$bbbb" ]}})
      { "_id" : ObjectId("55cce7defd4e487ca8f05319"), "bbbb" : [ null ] }
      { "_id" : ObjectId("55cce7defd4e487ca8f0531a"), "bbbb" : [ null ] }
      { "_id" : ObjectId("55cce7defd4e487ca8f0531b"), "bbbb" : [ null ] }
      { "_id" : ObjectId("55cce7defd4e487ca8f0531c"), "bbbb" : [ null ] }
      

      I would have expected aaaa to be missing and bbbb to be an empty array, not an array with explicit null. That seems more consistent with aaaa showing up with null value.

      Attachments

        Activity

          People

            charlie.swanson@mongodb.com Charlie Swanson
            asya.kamsky@mongodb.com Asya Kamsky
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: