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

$concatArrays not working on existing multi array field

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • 3.4.6
    • Aggregation Framework
    • None
    • ALL
    • Hide

      Given a collection:

      { _id: 1, items: [ [1, 2, 3], [4, 5, 6] ] }
       
      db.collection.aggregate([
         { $project: { items: { $concatArrays: "$items" } } }
      ])
      

      Result should be:

      { _id: 1, items: [1, 2, 3, 4, 5, 6] }
      

      Result is:

      { _id: 1, items: [ [1, 2, 3], [4, 5, 6] ] }
      

      Show
      Given a collection: { _id: 1, items: [ [1, 2, 3], [4, 5, 6] ] }   db.collection.aggregate([ { $project: { items: { $concatArrays: "$items" } } } ]) Result should be: { _id: 1, items: [1, 2, 3, 4, 5, 6] } Result is: { _id: 1, items: [ [1, 2, 3], [4, 5, 6] ] }
    • Query 2017-12-04

    Description

      The $concatArrays operator does not work when using a multi array field already in the collection.

      The current work around is to use $reduce with $concatArrays.

      Attachments

        Activity

          People

            david.storch@mongodb.com David Storch
            devnopt Joel Goldfinger
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: