Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-12144

Docs for SERVER-37182: Different values when referencing whole object vs. a field of that object after $arrayToObject

      Description

      Description:

      This line on the $arrayToObject documentation is incorrect:
      https://docs.mongodb.com/manual/reference/operator/aggregation/arrayToObject/

      "If the name of a field repeats in the array, $arrayToObject uses the first value for that field."

      BEFORE this fix, which field was used when there are repeats was language/driver dependent.

      AFTER this fix, the last field will always be used when there are repeats.

      Feel free to email me if you have any questions!

      Engineering Ticket Description:

      Using $arrayToObject on an array of {k: ..., v: ...} objects where some k are repeating outputs an object that behaves inconsistently.

      Referencing this object as a whole using "$object" outputs an object with a field value that is different compared to the value obtained by referencing the field directly using "$object.field".

      Scope of changes

      Impact to Other Docs

      MVP (Work and Date)

      Resources (Scope or Design Docs, Invision, etc.)

            Assignee:
            kay.kim@mongodb.com Kay Kim (Inactive)
            Reporter:
            kay.kim@mongodb.com Kay Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              5 years, 25 weeks, 6 days ago