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

Inclusion projection scenario that falsely writes included field to document

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 4.0.10, 4.3.1
    • Component/s: 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]);

      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
      

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

              Created:
              Updated:
              Resolved: