hmarr/mongoengine — Issue #419: Bug enforcing uniqueness after dropping collection
Author: rpeng
Created: 2012-02-01 09:56:51+00:00
State: open

Hey!

I've noticed that the uniqueness constraint isn't enforced anymore (doesn't raise OperationError) if the user drops the collection and tries to save again.

For example, let's say I have a document like so:

class Project(Document):
name = StringField(required = True, unique = True)

Then I do this:

first = Project(name="foo")
second = Project(name="foo")

first.save(safe=True)
second.save(safe=True) // raises OperationError as expected

Project.drop_collection()

first = Project(name="foo")
second = Project(name="foo")

first.save(safe=True)
second.save(safe=True) // does NOT raise OperationError