[SERVER-16752] Unique key constraints not enforced after dropDatabase() Created: 07/Jan/15 Updated: 08/Jan/15 Resolved: 08/Jan/15 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Index Maintenance |
| Affects Version/s: | 2.6.6 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Dan Helyar | Assignee: | Ramon Fernandez Marina |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Operating System: | ALL |
| Participants: |
| Description |
|
I have a Node project with WebDriver test suite that runs 'mongo [database] --eval "db.dropDatabase();"' before each test run. One of the tests attempts to create a duplicate record to test a {unique : true}constraint, however the record is saved no problem. The schema is defined by Mongoose. The same test gives duplicate key error if I don't run dropDatabase() beforehand. |
| Comments |
| Comment by Ramon Fernandez Marina [ 08/Jan/15 ] | |||||||||||||||||||||||
|
Yes, drop() and dropDatabase() will also remove any indexes you may have. I'm now closing this ticket, but please open new tickets if you run into other issues. Regards, | |||||||||||||||||||||||
| Comment by Dan Helyar [ 08/Jan/15 ] | |||||||||||||||||||||||
|
Apologies I've since learnt that I need to run ensureIndex or avoid dropDatabase() altogether otherwise the behaviour I'm experiencing should be expected. | |||||||||||||||||||||||
| Comment by Ramon Fernandez Marina [ 07/Jan/15 ] | |||||||||||||||||||||||
|
I tried a simple reproducer on my end, but was unable to see any bugs:
Can you please share more details on how the test to check the {unique : true} constraint looks like? |