[SERVER-4361] Upserts featuring $in and related operator criteria result in inconsistent behaviour depending on nesting level Created: 23/Nov/11  Updated: 07/Mar/14  Resolved: 23/Nov/11

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: 2.0.0, 2.0.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Remon van Vliet Assignee: Unassigned
Resolution: Done Votes: 0
Labels: $in, inconsistent, upsert
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

All


Operating System: ALL
Participants:

 Description   

Upserts with $in clause results in either the operator being added to the document or it being ignored depending on nesting depth :

> db.test.update({a:{$in:[1]}}, {$set:{v:1}}, true, false)
> db.test.find()

{ "_id" : ObjectId("4ecd047da0627e0c2e464b5e"), "v" : 1 }

> db.test.update({a:{b:{$in:[1]}}}, {$set:{v:1}}, true, false)
> db.test.find()
{ "_id" : ObjectId("4ecd0487a0627e0c2e464b5f"), "a" : { "b" :

{ "$in" : [ 1 ] }

}, "v" : 1 }

Is this intended? And if not which one is the correct behaviour?



 Comments   
Comment by Remon van Vliet [ 23/Nov/11 ]

Ah, silly me. Makes sense. Thanks

Comment by Scott Hernandez (Inactive) [ 23/Nov/11 ]

The first case is correct; it should be ignored.

In the second case it is not the query you think it is.

({a:{b:{$in:[1]}}}

It says, find me an "a" where the value is '{b:{$in:[1]}}'. Not find me an "a.b" which is 1.

If you want an embedded search then you should use dot-notation.

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