[SERVER-9442] Query results edited in javascript can create duplicate elements in the same document. Created: 23/Apr/13  Updated: 10/Dec/14  Resolved: 24/Apr/13

Status: Closed
Project: Core Server
Component/s: JavaScript, Querying
Affects Version/s: 2.4.1
Fix Version/s: None

Type: Bug Priority: Critical - P2
Reporter: Kevin Wingham 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-9066 Field names can be repeated in JavaSc... Closed
Operating System: Windows
Participants:

 Description   

After obtaining a set of documents from my MongoDB, I attempted to iterate through and add the element "Name" to each result, e.g.:

...
{
"_id" : 01234567890
},
...

becomes

...
{
"_id" : 01234567890,
"Name" : "Joe"
},
...

This was run on tens of thousands of entries. It almost always worked as expected, however it occasionally (1 - 5 across the entire dataset) produced entries which looked like this:

...
{
"_id" : 01234567890,
"Name" : "Joe",
"Name" : "Joe"
},
...

This data would then cause a corrupt entry when committed back to the DB.

I viewed this information printed directly from javascript, before committing back to the DB. I also noticed that if I explicitly set the variable "Name" twice back to back, it went ahead and duplicated the key every time, setting the values of both instances to the one most recently specified.

This does not happen if I create an array of test data right in JS, it ONLY occurred when modifying the results of a MongoDB query.



 Comments   
Comment by Kevin Wingham [ 23/Apr/13 ]

Yes that looks like exactly what it was! Apologies for reviving a solved bug, and thank-you for the help.

Comment by J Rassi [ 23/Apr/13 ]

I believe you're encountering SERVER-9066, which has been fixed in version 2.4.2 of the shell. Can you try this with the latest production release (2.4.3) of the shell and see if that fixes your issue? It's available at http://www.mongodb.org/downloads.

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