[SERVER-9637] Upsert with filters for a subdocument and a nested subdocument key result with an invalid BSON. (one document with two duplicate keys!) Created: 09/May/13  Updated: 06/Mar/14  Resolved: 09/May/13

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

Type: Bug Priority: Major - P3
Reporter: Alon Horev Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

OS X


Issue Links:
Related
related to SERVER-6439 Duplicate fields at the same level sh... Backlog
related to SERVER-718 in JS shell, duplicated fields should... Closed
Operating System: ALL
Participants:

 Description   

Have a look at the resulting document, the 'key' subdocument repeats twice!:

test> db.test.update({'key':

{'nested': 1}

, 'key.nested': 2}, {$set: {a:3}},

{upsert:true}

)
test> db.test.find()
{
"_id": ObjectId("518b90225fef1b6560f579c3"),
"a": 3,
"key":

{ "nested": 1 }

,
"key":

{ "nested": 1 }

}



 Comments   
Comment by Scott Hernandez (Inactive) [ 09/May/13 ]

There are two issues here:

  • Fields with the same name (repeated) at the same level in a document display incorrectly in the shell (and in other languages): SERVER-718
  • When creating the document to insert a duplicate field name is created in the document. However, that is explicitly what is described in the query portion used for the insert.

The second issue is not really a bug since currently we allow repeated fields in BSON/Documents. It may be unexpected behavior to some and is something we want to make less surprising without breaking existing applications. see SERVER-6439

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