hmarr / mongoengine

[Moved to mongoengine/mongoengine]
https://github.com/MongoEngine/mongoengine
MIT License
793 stars 20 forks source link

Queryset update doesn't go through field validation #589

Open alonho opened 11 years ago

alonho commented 11 years ago

Here's an example:

import mongoengine as me
me.connect('test')

class AgeField(me.IntField):
    def validate(self, value):
        if value < 0:
            self.error('must be larger than zero')

class Person(me.Document):
    age = AgeField()

try:
    Person(age=-2).save()
except me.ValidationError:
    pass
else:
    1/0
p = Person(age=100).save()
Person.objects.update(set__age=-1)
print Person.objects()[0].age