[SERVER-8303] $each on $push gives unexpected results when used alone Created: 23/Jan/13  Updated: 11/Jul/16  Resolved: 29/Jan/13

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: 2.3.2
Fix Version/s: 2.4.0-rc0

Type: Bug Priority: Major - P3
Reporter: Randolph Tan Assignee: Alberto Lerner
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to CSHARP-684 Add new features to Update builder fo... Closed
Operating System: ALL
Participants:

 Description   

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



 Comments   
Comment by auto [ 29/Jan/13 ]

Author:

{u'date': u'2013-01-29T17:55:04Z', u'email': u'alerner@10gen.com', u'name': u'Alberto Lerner'}

Message: SERVER-8303 Fix $push with a single $each clause behavior.
Branch: master
https://github.com/mongodb/mongo/commit/2b94e0e553d7b76b2c1a50c6e9bd6d0b4764e78c

Generated at Thu Feb 08 03:17:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.