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

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

    XMLWordPrintable

Details

    • Bug
    • Status: Investigating
    • Major - P3
    • Resolution: Unresolved
    • None
    • None
    • Querying
    • 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") }

    Description

      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. 

      Attachments

        Issue Links

          Activity

            People

              kateryna.kamenieva@mongodb.com Katya Kamenieva
              michael.gargiulo@mongodb.com Michael Gargiulo
              Votes:
              0 Vote for this issue
              Watchers:
              14 Start watching this issue

              Dates

                Created:
                Updated: