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

$merge changing structure of fields containing '.' in output collection

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • Query Optimization
    • ALL
    • Hide
      1. db.createCollection('mergeTest', {})
      2. db.'mergeTest'.insertOne( { "ts" : ISODate("2021-11-19T09:27:44.001Z"), "sensorId" : "abc2c", "quantity.goods" : 2.0, "price" : 10.0, "_id" : ObjectId("619c63912dfeb5ace44e3c32") })
      3. db.getCollection('mergeTest').aggregate([\{$limit : 1}, \\{$merge : "testing1"}])
      4. db.getCollection('testing1').findOne({})

      Output Results: 

      {
      "_id": ObjectId("619c63912dfeb5ace44e3c32"),
      "price": 10.0,
      "quantity":

      { "goods": 2.0 }

      ,
      "sensorId": "abc2c",
      "ts": ISODate("2021-11-19T09:27:44.001Z")
      }

      Show
      db.createCollection('mergeTest', {}) db.'mergeTest'.insertOne( { "ts" : ISODate("2021-11-19T09:27:44.001Z"), "sensorId" : "abc2c", "quantity.goods" : 2.0, "price" : 10.0, "_id" : ObjectId("619c63912dfeb5ace44e3c32") }) db.getCollection('mergeTest').aggregate( [\{$limit : 1}, \\{$merge : "testing1"}] ) db.getCollection('testing1').findOne({}) Output Results:   { "_id": ObjectId("619c63912dfeb5ace44e3c32"), "price": 10.0, "quantity": { "goods": 2.0 } , "sensorId": "abc2c", "ts": ISODate("2021-11-19T09:27:44.001Z") }

      When running an aggregation thats ends in $merge against any collection type the structure stored in the output collection for any field names containing a '.' is transformed to a nested objected resulting in a different format from the base collection. 

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            michael.gargiulo@mongodb.com Michael Gargiulo
            Votes:
            0 Vote for this issue
            Watchers:
            17 Start watching this issue

              Created:
              Updated: