-
Type: Improvement
-
Resolution: Duplicate
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
Query
According to the documentation, when $arrayToObject is used on an array where some keys repeat, the value of the first key is used.
However, as far as I can see, this behaviour is not being tested for in the jstests integration test.
I propose adding the following test to jstests/aggregation/expressions/arrayToObject.js:
// check that if two keys are equal, the value of the first key is used assert.writeOK(coll.insert({_id: 26, expanded: [["same", 1], ["same", 2]]})); result = coll.aggregate([{$match: {_id: 26}}, array_to_object_expr]).toArray(); assert.eq(result, [{_id: 26, collapsed: {"same": 1}}]);
- duplicates
-
SERVER-37182 Different values when referencing whole object vs. a field of that object after $arrayToObject
- Closed