[SERVER-32250] v3.6 $setOnInsert may create objects with dots in field names Created: 10/Dec/17  Updated: 10/Dec/17  Resolved: 10/Dec/17

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 3.6.0
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Roman Kuzmin Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-29594 "update" can produce documents with d... Closed
Operating System: ALL
Participants:

 Description   

v3.6 $setOnInsert may create objects with dots in field names

v3.4 used to fail in this case because dots are not allowed in field names.
I did not find anything related in release notes, so it looks like a potential regression.

The following command adds a document which sub-document has a field "bad.1"

{{> db.test.update({y : {y :

{"bad.1" : 1}

} }, {$setOnInsert :

{x : 42}

},

{upsert : true}

)
WriteResult(

{ "nMatched" : 0, "nUpserted" : 1, "nModified" : 0, "_id" : ObjectId("5a2d066a88785e4c179faaa1") }

)

> db.test.find()
{ "_id" : ObjectId("5a2d066a88785e4c179faaa1"), "y" : { "y" :

{ "bad.1" : 1 }

}, "x" : 42 }
}}



 Comments   
Comment by Tess Avitabile (Inactive) [ 10/Dec/17 ]

Hello nightroman,

Thank you for checking about this. This behavior is in fact intentional. Please see the discussion on SERVER-29594 for details.

Best,
Tess

Comment by Roman Kuzmin [ 10/Dec/17 ]

Another example is with $addToSet. It failed in 3.4 and works in 3.6.
As a result a sub-document with "bad.1" is added

db.test.save(

{ _id: 1, letters: ["a", "b"] }

)

db.test.update(

{ _id: 1 }

,
{ $addToSet: {letters:

{"bad.1" : 1}

} }
)

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