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

Multiple $slice on fixed sized array causes wrong/duplicate elements

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

      db.fs.update(

      {x:4}

      ,{ $push : { y : { $each : [

      {a:5}

      ,

      {a:1}

      ,

      {a:4}

      ,

      {a:2}

      ,

      {a:3}

      ], $slice:-4, $slice:-3, $sort:

      {a:1}

      } } })

      db.fs.find()
      { "_id" : ObjectId("50fd0989a8f4e3eef998f845"), "x" : 4, "y" : [

      { "a" : 4 }

      ,

      { "a" : 4 }

      ,

      { "a" : 5 }

      ] }

      Show
      db.fs.update( {x:4} ,{ $push : { y : { $each : [ {a:5} , {a:1} , {a:4} , {a:2} , {a:3} ], $slice:-4, $slice:-3, $sort: {a:1} } } }) db.fs.find() { "_id" : ObjectId("50fd0989a8f4e3eef998f845"), "x" : 4, "y" : [ { "a" : 4 } , { "a" : 4 } , { "a" : 5 } ] }

      Doing a $push with multiple $slice for fixed sized arrays causes wrong/duplicate elements.

            Assignee:
            Unassigned Unassigned
            Reporter:
            sam.weaver Sam Weaver
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: