Uploaded image for project: 'MongoDB ETL Tools'
  1. MongoDB ETL Tools
  2. TOOLS-55

mongoimport / mongod accepts JSON documents with duplicate keys

    XMLWordPrintable

    Details

      Description

      It is possible to import the following document into mongo using mongimport

      { "_id" : { "$oid" : "4e2f0a99a26037e417000056" }, "info" : { "Qu" : { "start" : "a", "stop" : 1320779121 }, "Se" : { "start" : 1320021628, "stop" : 1320779121 }, "Se I" : { "start" : "a", "stop" : 1320779121 }, "Se I_Se M" : { "start" : "a", "stop" : 1320779121 }, "Se M" : { "start" : "a", "stop" : 1320779121 }, "Se" : { "start" : "a" }, "So" : { "start" : "a", "stop" : 1320779121 } } }

      In this case info.Se is duplicated. No error is generated. Reading this document from the mongoshell or through the PHP driver gives different outputs (since different languages handle this differently).

      Shouldn't it be up to the mongo server to ensure that every key in every document is unique and generate warnings/exceptions when this is not the case ? I can't see any reason why the server should handle duplicate keys ...

        Attachments

          Activity

            People

            • Assignee:
              backlog-server-tools Backlog - Server Tools Team
              Reporter:
              ian.whalen Ian Whalen
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: