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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 3.1.8
    • Component/s: Aggregation Framework
    • None
    • Fully Compatible
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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.

            Assignee:
            Charlie Swanson
            Reporter:
            Asya Kamsky
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: