[SERVER-2028] Null values should (optionally) be ignored by unique indexes Created: 29/Oct/10  Updated: 17/Jul/11  Resolved: 29/Oct/10

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: 1.7.1
Fix Version/s: None

Type: New Feature Priority: Minor - P4
Reporter: Remon van Vliet Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

All


Participants:

 Description   

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.



 Comments   
Comment by Eliot Horowitz (Inactive) [ 17/Jul/11 ]

@federico, look at linked SERVER-484 that does what you want. you make an index unique and sparse.

Comment by Federico Grillini [ 15/Jul/11 ]

Hi,
I'm evaluating MongoDB for a document management system.
The feature requested in this issue would be very useful for me (or better, it would be fundamental).
Looking at the issue's status (closed) and resolution (duplicate), I don't understand if there's another
planned issue about null values in unique indexes or if this new feature won't be planned in future versions
of MongoDB.
Could someone dispel my doubts?

Thanks a lot!

Comment by Eliot Horowitz (Inactive) [ 29/Oct/10 ]

SERVER-484

Generated at Thu Feb 08 02:58:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.