-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
None
-
Affects Version/s: 2.0.0
-
Component/s: Index Maintenance
-
None
-
Query
-
ALL
This seems to be a change in behaviour between 1.8 and 2.0:
With v1.8.1:
MongoDB shell version: 1.8.1
connecting to: odyssey_test > use foo_test switched to db foo_test > db.users.ensureIndex({aliases:1},{sparse:true,unique:true}) > db.users.insert({name:"alice", aliases:[]}) > db.users.insert({name:"bob", aliases:[]}) > db.users.find() { "_id" : ObjectId("4e7b5b219521a5c75ce16608"), "name" : "alice", "aliases" : [ ] } { "_id" : ObjectId("4e7b5b289521a5c75ce16609"), "name" : "bob", "aliases" : [ ] }
with v2.0.0:
MongoDB shell version: 2.0.0
connecting to: test > use foo_test switched to db foo_test > db.users.ensureIndex({aliases:1},{sparse:true,unique:true}) > db.users.insert({name:"alice", aliases:[]}) > db.users.insert({name:"bob", aliases:[]}) E11000 duplicate key error index: foo_test.users.$aliases_1 dup key: { : undefined }
If I instead create the index with v:0 (to force old-style, pre-v2.0 index type), I don't get the dup key error, i.e. same behaviour as 1.8 (as you would expect).
Is this intended? I don't see anything in release notes...