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

Inclusion projection scenario that falsely writes included field to document

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • 4.0.10, 4.3.1
    • Aggregation Framework
    • ALL
    • Hide

      db.coll.drop();
      db.coll.insert({});
      db.coll.createIndex({"str": 1});
       
      var result =
          db.coll.aggregate([{$match: {'str': {$not: {$eq: ''}}}},
                                               {$project: {"str": 1, "_id": 0}}]).toArray();
      assert.eq({}, result[0]);
      

      Show
      db.coll.drop(); db.coll.insert({}); db.coll.createIndex({"str": 1});   var result = db.coll.aggregate([{$match: {'str': {$not: {$eq: ''}}}}, {$project: {"str": 1, "_id": 0}}]).toArray(); assert.eq({}, result[0]);

    Description

      In the reproduction below an aggregate with match and inclusion projection writes the included field to the output document. It should instead produce an empty document. This is consistently reproducible on 4.0.10 and occurs sporadically on master and 4.2.0-rc0.

      The assertion fails with the following error:

      assert: [{ }] != [{ "str" : null }] are not equal
      

      Attachments

        Activity

          People

            james.wahlin@mongodb.com James Wahlin
            james.wahlin@mongodb.com James Wahlin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: