Skip to content

Default to safe operations #152

@gardenia

Description

@gardenia

Hi,

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.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions