iwind/rockmongo

Error "not okForStorage" modifying document with dots in the keys

Opened this issue · 2 comments

I've created a document with this content:

{
  "codigo": "cochesnet_tipo_cambio",
  "tipo": "regex",
  "valores": {
    "(?i).*(Automático).*": "1",
    "(?i).*(Manual).*": "2"
  }
}

When insert the document, works fine but when I try to modify it, I get the error:
not okForStorage

Using robomongo I can modify the document without problems but not with rockmongo

Dots (and $) are not allowed in key names because the MongoDB server reserves this syntax for embedded field/array references (see MongoDB manual: Restrictions on Fields Names). The MongoDB documentation suggests an alternate approach of using Unicode full width equivalents if you want to have something that looks like ., however that probably isn't helpful if you are storing regular expressions.

Some versions of MongoDB drivers/server did not fully enforce this restriction and it looks like you have documents that need to be corrected.

If Robomongo is allowing you to insert or edit documents with invalid key values, can you please create a Robomongo issue to investigate including the version of Robomongo and MongoDB server you are using?

I tried to reproduce this issue with Robomongo 0.8.4 and MongoDB 2.6.4 and got the expected exception:

can't have . in field names [(?i).*(Automático).*]

I see, in theory it is not allowed (unless using Unicode)

With mongodb version 2.4.6 and robomongo 0.8.4 I can use these names for insert and update. With rockmongo I can create a new document with these field names without problem, the error is only on update.

I don't know why it works (perhaps robomongo encode in unicode before send the update)... but I'll change the data structure to not use dots in the field names.

Thanks for all stennie!