[SERVER-1798] Dot notation and array notation oddities Created: 15/Sep/10  Updated: 12/Jul/16  Resolved: 16/Sep/10

Status: Closed
Project: Core Server
Component/s: JavaScript, Shell
Affects Version/s: 1.6.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Van Nguyen (vnguyen) Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Centos5, MongoDB version 1.6.1-pre-


Operating System: Linux
Participants:

 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



 Comments   
Comment by Van Nguyen (vnguyen) [ 16/Sep/10 ]

This specific bug is fixed in the latest nightlies and thus can be closed. But a more specific side case has been reopened as a separate JIRA issue here:

http://jira.mongodb.org/browse/SERVER-1805

Comment by Van Nguyen (vnguyen) [ 15/Sep/10 ]

This happens in both the javascript console and through the PHP driver.

In short:

If I do an update with a {$set:{"key.subkey":x}}, should it match key.* and set every subkey to x? >_>

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