Created
March 24, 2011 15:15
-
-
Save tfausak/885218 to your computer and use it in GitHub Desktop.
Minimal example that causes a mysterious uniqueness constraint when inserting into mongoengine.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Traceback (most recent call last): | |
File "unique.py", line 15, in <module> | |
B(foo=True).save() | |
File "/usr/local/lib/python2.6/dist-packages/mongoengine-0.4-py2.6.egg/mongoengine/document.py", line 85, in save | |
mongoengine.queryset.OperationError: Tried to save duplicate unique keys (E11000 duplicate key errorindex: tmp-unique.a.$foo_1 dup key: { : null }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mongoengine import * | |
class A(Document): | |
pass | |
class B(A): | |
foo = BooleanField(unique=True) | |
connect('tmp-unique') | |
A.drop_collection() | |
B.drop_collection() | |
A().save() | |
A().save() | |
B(foo=True).save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment