Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Mongoengine runs validate on non changed fields before saving. #579

tabdulradi opened this Issue Jan 3, 2013 · 3 comments


None yet
2 participants
class User(Resource):
    state = IntField(required=True)
    name = SmallStringField(required=True)

u = User()
u.state = 1
u.name = "Tamer"

u1 = User.objects.only('name').first()
u1.name = "Radian"
u1.save() # Fails because state is required

Mongoengine runs validate on all fields before save, even if there they are not changed. Which cases the above problem. I suggest save should validate changed fields only.

I am running the stable Mongoengine version from pip.

rozza commented Jan 3, 2013

I can understand why thats an issue in that case - but I'm unsure if its the right way to go.

Save calls validate to validate the model before saving, this seems sensible to me. If I added checks to validate only changed fields, I'm sure that there'd be a ticket logging that invalid documents could be saved..

rozza commented Jan 3, 2013

Also - please log this in the official repo - for further conversations: https://github.com/MongoEngine/mongoengine

@rozza rozza closed this Jan 3, 2013

Logged here MongoEngine#208

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment