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

Pipeline stage $set fails to set a non-existent dotted field to an object

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Critical - P2 Critical - P2
    • 4.4.0-rc12, 4.7.0
    • Affects Version/s: 4.4.0-rc9
    • Component/s: None
    • None
    • Fully Compatible
    • ALL
    • v4.4
    • Query 2020-06-29, Query 2020-07-13

      This bug showed up when I was trying to run a multiversion update-fuzzer task against V4.4 and V4.2. On 4.2 we can set a non-existent dotted field to an object,

      > db.fuzzer.aggregate([{$set: {"a.b": {a: 1}}}])
      { "_id" : ObjectId("5ee0a7bf3fe8d86b4e667fe5"), "a" : { "b" : { "a" : 1 } } }
      

      But on 4.4 and master, this command would somehow result in a no-op. e.g.

      > db.fuzzer.find()
      { "_id" : ObjectId("5edfd55b7e4f068196bef40e") }
      
      > db.fuzzer.aggregate([{$set: {"a.b": {a: 1}}}])
      { "_id" : ObjectId("5edfd55b7e4f068196bef40e") }
      

      Though we can still set a non-existent simple field to an object or set a dotted field to a simple non-object value on master. e.g.

      > db.fuzzer.aggregate([{$set: {"a.b": 1}}])
      { "_id" : ObjectId("5edfd55b7e4f068196bef40e"), "a" : { "b" : 1 } }
      
      > db.fuzzer.aggregate([{$set: {"a": {a: 1}}}])
      { "_id" : ObjectId("5edfd55b7e4f068196bef40e"), "a" : { "a" : 1 } }
      

            Assignee:
            arun.banala@mongodb.com Arun Banala
            Reporter:
            ruoxin.xu@mongodb.com Ruoxin Xu
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: