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

Null values should (optionally) be ignored by unique indexes

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Duplicate
    • Affects Version/s: 1.7.1
    • Fix Version/s: None
    • Component/s: Index Maintenance
    • Labels:
      None
    • Environment:
      All

      Description

      The documentation states :
      "When a document is saved to a collection with unique indexes, any missing indexed keys will be inserted with null values. Thus, it won't be possible to insert multiple documents missing the same indexed key.".

      This is very unpractical in a lot of situations and Mongo should offer the option to allow a field indexed with a uniquess constraint to be null for more than one document.

      Something like ensureIndex(

      {firstname: 1, lastname: 1}

      ,

      {unique: true, multipleNulls:true}

      would be nice and it should be fairly trivial to add.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            remonvv Remon van Vliet
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: