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

Dot notation and array notation oddities

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 1.6.1
    • JavaScript, Shell
    • None
    • Centos5, MongoDB version 1.6.1-pre-
    • Linux

    Description

      Hi,

      We're modifying a document's key/value pair where key is a string that = "sent". The value of "sent" is an object or associative array which in the example has two possible keys: "100001140891858" and "100001181664410". We're trying to reference the values for each of those two subkeys.

      Here is a pastebin of what happens when we use dot notation: http://pastebin.com/wSnTGSaD
      Here is a pastebin of a similar scenario with array notation: http://pastebin.com/UAYuMZGu

      In the dot notation example, we first populate the document with sent.100001140891858. Then, if you look carefully, the second update does a: $set "sent.100001181664410.to_id" to "100001181664410" and updates the created_at. If you look in the result of the object after that update, both subkeys have the same data which comes from the second update. We are expecting Mongo to respond with the separate data. Are we doing this wrong?

      I setup a second example with array notation which sort of illustrate a similar case. In this example, the second update still uses dot notation to reference a subdocument's subdoc but ends up completely overwriting the value of "sent".

      We're not sure what's going wrong and one engineer pulled his hair out in frustration >_>. Thanks for your time and help!

      Best Regards,
      Van

      Attachments

        Activity

          People

            Unassigned Unassigned
            van Van Nguyen (vnguyen)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: