[DOCS-12144] Docs for SERVER-37182: Different values when referencing whole object vs. a field of that object after $arrayToObject Created: 15/Oct/18  Updated: 13/Nov/23  Resolved: 27/Nov/18

Status: Closed
Project: Documentation
Component/s: manual, Server
Affects Version/s: None
Fix Version/s: 4.1.4, 4.0.5, 3.6.10, 3.4.19, Server_Docs_20231030, Server_Docs_20231106, Server_Docs_20231105, Server_Docs_20231113

Type: Task Priority: Major - P3
Reporter: Kay Kim (Inactive) Assignee: Kay Kim (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
documents SERVER-37182 Different values when referencing who... Closed
Participants:
Days since reply: 5 years, 2 weeks, 2 days ago
Epic Link: DOCS: 4.2 Server/Tools

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



 Comments   
Comment by Githook User [ 28/Jan/19 ]

Author:

{'email': 'kay.kim@mongodb.com', 'name': 'Kay Kim'}

Message: DOCS-12144: $arrayToObject repeating field
Branch: v3.4
https://github.com/mongodb/docs/commit/bfd83bb1128adf942a363a05ca8162f484b2333f

Comment by Githook User [ 22/Jan/19 ]

Author:

{'email': 'kay.kim@mongodb.com', 'name': 'Kay Kim'}

Message: DOCS-12144: $arrayToObject repeating field
Branch: v3.6
https://github.com/mongodb/docs/commit/ad99d16986c42f16bf3841e306e375448d64a7bb

Comment by Githook User [ 22/Jan/19 ]

Author:

{'email': 'kay.kim@mongodb.com', 'name': 'Kay Kim'}

Message: DOCS-12144: $arrayToObject repeating field
Branch: v3.4.19
https://github.com/mongodb/docs/commit/a251b543ae86ab98795a958d00050dfa56da8012

Comment by Githook User [ 20/Dec/18 ]

Author:

{'email': 'kay.kim@mongodb.com', 'name': 'Kay Kim'}

Message: DOCS-12144: $arrayToObject repeating field
Branch: v4.0
https://github.com/mongodb/docs/commit/ad750611558fa1af3631ad5df7446526e9c371a0

Comment by Githook User [ 27/Nov/18 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@mongodb.com'}

Message: DOCS-12144: $arrayToObject repeating field
Branch: v3.4.19
https://github.com/mongodb/docs/commit/68c159b6e1f29af1ea0cbcd6b81bf1cc11a3771c

Comment by Githook User [ 27/Nov/18 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@mongodb.com'}

Message: DOCS-12144: $arrayToObject repeating field
Branch: v3.6.10
https://github.com/mongodb/docs/commit/fd0d015c3784043716e6500e5841211fa6e3d60f

Comment by Githook User [ 27/Nov/18 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@mongodb.com'}

Message: DOCS-12144: $arrayToObject repeating field
Branch: v4.0.5
https://github.com/mongodb/docs/commit/b3250cce8762e6576bc873716176d5455ecc8b28

Comment by Githook User [ 27/Nov/18 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@mongodb.com'}

Message: DOCS-12144: $arrayToObject repeating field
Branch: master
https://github.com/mongodb/docs/commit/19de3617b53131afe21780f7117f33e6c1d242f4

Comment by Githook User [ 26/Nov/18 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@mongodb.com'}

Message: DOCS-12144: 4.0-4.0.4 behavior
Branch: v4.0
https://github.com/mongodb/docs/commit/b3be1b9602eae6ea1fde7a878b3d4476002ac28b

Comment by Githook User [ 26/Nov/18 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@mongodb.com'}

Message: DOCS-12144: 4.0-4.0.4 behavior
Branch: v3.6
https://github.com/mongodb/docs/commit/ed48cb74a4497c6baf3ec5599c947e6348e1f9ec

Comment by Ian Boros [ 21/Nov/18 ]

kay.kim Early next week is fine. Thanks for your quick response!

Comment by Ian Boros [ 20/Nov/18 ]

After more discussion, we've realized this bug combined with the incorrect documentation could cause some real confusion for users. kay.kim Would it be possible for the docs team to prioritize this ticket? Or at least, possible to prioritize a fix for the incorrect documentation here (in all versions) about the first value for a field being used in $arrayToObject (see description above). We're a little nervous over here about people reading about behavior which we don't support.

Comment by Ian Boros [ 19/Nov/18 ]

Please note that this change has been backported to 3.4, 3.6 and (soon) 4.0. See the server ticket for more details, but we should make sure to update the documentation for all of the versions.

Generated at Thu Feb 08 08:04:29 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.