Null values should (optionally) be ignored by unique indexes

XMLWordPrintableJSON

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

      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
              Reporter:
              Remon van Vliet
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: