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

    XMLWordPrintable

Details

    • Task
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 4.1.4, 4.0.5, 3.6.10, 3.4.19
    • manual, Server
    • None

    Description

      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.)

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:
                3 years, 21 weeks, 6 days ago