[Answered ]-StringField is defined as unique, but duplicates are saved silently

2👍

That is may be required drop_collection.

def test_company3():
    """ test company2 """
    Company.drop_collection()
    company = Company(screen_name='asdasd')
    company.save()
    company = Company(screen_name='asdasd')
    with nt.assert_raises(OperationError):
        company.save()
    pprint([(x.id, x.screen_name,) for x in Company.objects.all()])

See this tests. Mongoengine is all tests is passed.
https://github.com/hmarr/mongoengine/blob/master/tests/document.py#L875

Mongoengine team Recently relaeed 0.6.3.

👤Ankhaa

Leave a comment