Skip to content
This repository

Default to safe operations #152

gardenia opened this Issue August 30, 2012 · 1 comment

2 participants

gardenia Jonas Haag


If I do:

MyModel.objects.update(title="blah blah")

The return value of the update() is None by default.

I am aware that this behaviour can be controlled with the "OPTIONS" element when setting the DB engine:

'default' : {
    'ENGINE': 'django_mongodb_engine',
    'NAME': 'test',
    'OPTIONS': {'OPERATIONS': {'safe': True}}

.. and that doing so will make update() calls return the number of rows affected.

However, the documented Django behaviour is that this will return the number of rows affected. So the default behaviour of django_mongodb_engine differs from other drivers.

I would argue that safe mode should be the default, not an optional flag, such that the default behaviour is the same as sqlite, MySQL etc. If there is a performance reason for disabling "safe" updates then it seems more natural that people should have to explicitly disable safe mode with the caveat that they lose the "number of rows affected" return value as a trade-off.


Jonas Haag

Sounds legit, setting for 0.5 release, patches welcome

(I actually think we made this change a while ago but can't remember all the details...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.