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

Impossible to select a subdocument with blank field name ( "" )

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Duplicate
    • Affects Version/s: 2.4.3
    • Fix Version/s: None
    • Component/s: Querying, Shell
    • Labels:
    • Environment:
      Possibly all.
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      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.

      Show
      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.

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              tunnuz Tommaso Urli
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: