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

Unique index with sparse does not work

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.8.2
    • Component/s: Index Maintenance
    • Labels:
      None
    • Environment:
      Windows 7
    • ALL

      In my mongo shell, I do this:

      db.members.ensureIndex(

      {facebook_id:1}

      ,

      {unique:true,sparse:true}

      )

      • I also try db.members.ensureIndex( {facebook_id:1}

        ,

        {sparse:true,unique:true}

        )

      Then I try to insert 2 records with facebook_id = null

      I have got this message:

      E11000 duplicate key error index: writepub.members.$facebook_id_1 dup key: { :null }

            Assignee:
            Unassigned Unassigned
            Reporter:
            tanin47 Tanin Na Nakorn
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: