Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-15074

[TOOLS] mongoimport / mongod accepts JSON documents with duplicate keys

    • Type: Icon: Task Task
    • Resolution: Won't Fix
    • Server_Docs_20231030
    • Affects Version/s: None
    • Component/s: tools
    • Labels:
      None

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

            Assignee:
            Unassigned Unassigned
            Reporter:
            Anonymous Anonymous
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              2 years, 12 weeks ago