[SERVER-9693] Impossible to select a subdocument with blank field name ( "" ) Created: 15/May/13  Updated: 20/Aug/14  Resolved: 20/Aug/14

Status: Closed
Project: Core Server
Component/s: Querying, Shell
Affects Version/s: 2.4.3
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Tommaso Urli Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: query
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Possibly all.


Issue Links:
Duplicate
duplicates SERVER-6852 Disallow empty path components in doc... Backlog
Related
Operating System: ALL
Steps To Reproduce:

1. Insert (e.g. through pymongo) a document containing a subdocument with an empty key field.
2. Try to query the specific field (the one with "" key).
3. Try to rename the specific key.

Participants:

 Description   

Situation: some MongoDB documents have subdocuments that contain an empty key, e.g. (I stripped ObjectIDs to make the code look nicer):

{ 
    "_id" : ObjectId("..."), 
    "stats" : 
        { 
            "violations" : 0, 
            "cost" : 170, 
        }, 
    "parameters" : 
        { 
            "" : "../instances/comp/comp20.ectt", 
            "repetition" : 29, 
            "time" : 600000 
        }, 
    "batch" : ObjectId("..."), 
    "system" : "Linux 3.5.0-27-generic", 
    "host" : "host3", 
    "date_started" : ISODate("2013-05-14T16:46:46.788Z"), 
    "date_stopped" : ISODate("2013-05-14T16:56:48.483Z"), 
    "copy" : false
}

The problem is line:

"" : "../instances/comp/comp20.ectt"

it is impossible to get back the value of the field. Querying doesn't work:

db.experiments.find(

{"batch": ObjectId("...")}

,

{ "parameters.": 1 }

)

gets the full content of the parameters subdocument. (My guess is that "." is probably ignored if followed by an empty selector.) From the JSON specification (15.12.*) it looks like empty keys are allowed.
Moreover, renaming doesn't work either, for similar reasons.



 Comments   
Comment by Thomas Rueckstiess [ 20/Aug/14 ]

Resolving this as a duplicate of SERVER-6852.

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