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.

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor - P4
    • Resolution: Duplicate
    • 2.4.6
    • None
    • 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 } >

    Description

      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'.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: