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

decide on behavior to $unwind an empty array

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.2.0-rc0
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • Labels:
      None

      The documentation says $unwind of an empty array passes through the source document unchanged. There are code comments stating that the behavior is to replace the empty array with a null value when unwinding. The actual behavior appears to be that the array field is removed from the document.

      c = db.c;
      c.drop();
      
      c.save( { a:[] } );
      printjson( c.aggregate( { $unwind:'$a' } ) );
      

            Assignee:
            aaron Aaron Staple
            Reporter:
            aaron Aaron Staple
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: