Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-37198

Add tests for $arrayToObject behaviour when two keys are identical

    XMLWordPrintable

    Details

      Description

      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}}]);
      

       

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: