Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-9442

Query results edited in javascript can create duplicate elements in the same document.

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Critical - P2 Critical - P2
    • None
    • Affects Version/s: 2.4.1
    • Component/s: JavaScript, Querying
    • None
    • Windows

      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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            kwingham Kevin Wingham
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: