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

Null values should (optionally) be ignored by unique indexes

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

      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.

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

              Created:
              Updated:
              Resolved: