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

Warn that documents with duplicate key names are not supported

    XMLWordPrintableJSON

Details

    Description

      Description

      Low level BSON helpers in some drivers (for example, the BSON writer in the Java driver) can be abused to create documents with duplicate key names. For example:

      {'foo': 'bar',
       'foo': 'bim',
       'foo': 'bam'}
      

      The BSON spec is silent on the issue of duplicate key names. The server's behavior when confronted with duplicate key names is undefined. Since drivers generally use a map to represent a BSON document, only one of the keys will survive decoding and reinsertion of such a document.

      A good place to add this might be https://docs.mongodb.com/manual/reference/limits/#Restrictions-on-Field-Names but the text should really be a warning / call to action.

      Scope of changes

      Impact to Other Docs

      MVP (Work and Date)

      Resources (Scope or Design Docs, Invision, etc.)

      Attachments

        Activity

          People

            nathan.contino@mongodb.com Nathan Contino (Inactive)
            bernie@mongodb.com Bernie Hackett
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              4 years, 22 weeks, 1 day ago