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

$each on $push gives unexpected results when used alone

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.4.0-rc0
    • Affects Version/s: 2.3.2
    • Component/s: Write Ops
    • None
    • ALL

      db.user.insert({ x: [] });
      db.user.update({ }, { $push: { x: { $each: [1, 2, 3] }}});
      db.user.update({ }, { $push: { x: { $each: [4, 5, 6] }}});
      db.user.update({ }, { $push: { x: { $each: [7, 8, 9], $slice: -10 }}});
      

      Gives you the result:

      { "_id" : ObjectId("51003755fc4e31f51fe6a84b"), "x" : [ [ 1, 2, 3 ], [ 4, 5, 6 ], 7, 8, 9 ] }
      

      As a user, I was expecting the result to look something like this:

      { "_id" : ObjectId("51003755fc4e31f51fe6a84b"), "x" : [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] }
      

            Assignee:
            alerner Alberto Lerner
            Reporter:
            randolph@mongodb.com Randolph Tan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: