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

    • Type: Task
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.1.4, 4.0.5, 3.6.10, 3.4.19
    • Component/s: manual, Server
    • Labels:
      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

              Assignee:
              kay.kim Kay Kim (Inactive)
              Reporter:
              kay.kim Kay Kim (Inactive)
              Participants:
              Last commenter:
              Githook User Githook User
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since reply:
                2 years, 44 weeks, 5 days ago
                Date of 1st Reply: