[SERVER-6047] $pullAll causes empty embedded object field to be created Created: 08/Jun/12  Updated: 11/Jul/16  Resolved: 03/Jul/12

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: None
Fix Version/s: 2.0.7, 2.2.0-rc0

Type: Bug Priority: Minor - P4
Reporter: Michael O'Brien Assignee: Richard Kreuter (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by JAVA-827 Support SASL PLAIN authentication Closed
Related
is related to SERVER-6124 $unset may create a nested field if i... Closed
Operating System: ALL
Participants:

 Description   

This looks like unusual behavior.

For example with a document like:

{ "_id" : ObjectId("4fd2736696a0c5567029c674"), "x" : 10 }

Issuing an update with $pullAll on a key that does not exist inside an embedded doc causes the field to be created:

db.test.update(

{x:10}

, {$pullAll : {"test.a" : ["foo", "bar"]}})

The (empty) embedded object "test" will now exist in the doc:
> db.test.find()
{ "_id" : ObjectId("4fd2736696a0c5567029c674"), "test" : { }, "x" : 10 }

I would have expected no change in the document's fields if the $pullAll references a key that does not exist.



 Comments   
Comment by auto [ 02/Jul/12 ]

Author:

{u'date': u'2012-07-02T12:12:34-07:00', u'name': u'Richard Kreuter', u'email': u'richard@10gen.com'}

Message: Don't grow a document on $pull/$pullAll. SERVER-6047
Branch: v2.0
https://github.com/mongodb/mongo/commit/bf25d51addc8fee6ca4d280df1da2550e9155629

Comment by auto [ 02/Jul/12 ]

Author:

{u'date': u'2012-07-02T12:39:41-07:00', u'name': u'Eric Milkie', u'email': u'milkie@10gen.com'}

Message: fix compile SERVER-6047
Branch: master
https://github.com/mongodb/mongo/commit/044844545c419c793d88e5521652a59402b8feb6

Comment by auto [ 02/Jul/12 ]

Author:

{u'date': u'2012-07-02T12:12:34-07:00', u'email': u'richard@10gen.com', u'name': u'Richard Kreuter'}

Message: Don't grow a document on $pull/$pullAll. SERVER-6047
Branch: master
https://github.com/mongodb/mongo/commit/7a43c2260ee58f82fc44e55c021b74d821e4a16e

Comment by Richard Kreuter (Inactive) [ 20/Jun/12 ]

For what it's worth, $pull does this, too.

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