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

dropDups option for ensureIndex method's option doesn't treat number one as a truthy value.

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.4.6
    • Component/s: Admin
    • None
    • Minor Change
    • Hide
      $ mongo
      MongoDB shell version: 2.4.6
      of files is 256, should be at least 1000
      > db.foo.insert({'key':1});
      >[db.foo.insert({'key':1});
      > db.foo.ensureIndex({key:1}, {unique:1, dropDups:1});
      {
      	"err" : "E11000 duplicate key error index: test.foo.$key_1  dup key: { : null }",
      	"code" : 11000,
      	"n" : 0,
      	"connectionId" : 23,
      	"ok" : 1
      }
      > 
      
      Show
      $ mongo MongoDB shell version: 2.4.6 of files is 256, should be at least 1000 > db.foo.insert({ 'key' :1}); >[db.foo.insert({ 'key' :1}); > db.foo.ensureIndex({key:1}, {unique:1, dropDups:1}); { "err" : "E11000 duplicate key error index: test.foo.$key_1 dup key: { : null }" , "code" : 11000, "n" : 0, "connectionId" : 23, "ok" : 1 } >

      ensureIndex treats number one for unique key (

      {unique: 1}

      ) as a truthy value, but for dropDups key, number one (

      {dropDups: 1}

      ) is invalid. dropDups only accept 'true'.

            Assignee:
            Unassigned Unassigned
            Reporter:
            shibu Yoshiki Shibukawa
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: