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

mongoimport / mongod accepts JSON documents with duplicate keys

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: mongoimport
    • Needed

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

            Assignee:
            Unassigned Unassigned
            Reporter:
            ian@mongodb.com Ian Whalen (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: