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

Unsets done by update aggregation pipelines show up as replacement on change streams

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 7.0.5, 6.0.13, 5.0.24
    • Component/s: None
    • Labels:
      None
    • Query Execution
    • ALL
    • Hide

      db.test.insertOne({_id: 'foo', 'a': 0});

      // Watch the change stream

      const watchCursor = db.test.watch();

      while (!watchCursor.isClosed()) { let next = watchCursor.tryNext(); while (next !== null)

      { printjson(next); next = watchCursor.tryNext(); }

      }

      // In another shell

      db.test.updateOne({_id: 'foo'}, [{$unset: ['a']}]);

      Show
      db.test.insertOne({_id: 'foo', 'a': 0}); // Watch the change stream const watchCursor = db.test.watch(); while (!watchCursor.isClosed()) { let next = watchCursor.tryNext(); while (next !== null) { printjson(next); next = watchCursor.tryNext(); } } // In another shell db.test.updateOne({_id: 'foo'}, [{$unset: ['a'] }]);

      Running an update with an aggregation pipeline with an `$unset` stage results in a change stream event of `replace`, instead of `update` with the corresponding fields marked as `removedFields`

            Assignee:
            Unassigned Unassigned
            Reporter:
            kartalkaan.bozdogan@ocell.io Kartal Kaan Bozdoğan
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: