Skip to content

model update doing two reads? #104

Open
@jacobg

Description

@jacobg

From looking at djangoappengine.db.compiler.SQLUpdateCompiler, it seems that an update reads a model entity from datastore a second time in order to save. That is, if I have a Django code like this:

my_entity = MyModel.objects.get(id=id) # reads from datastore
my_entity.my_field = 'something'
my_entity.save() # reads a second time, then writes to datastore

The first line of code obviously reads the model from the datastore. But based on the SQLUpdateCompiler.update_entity implementation, it looks like the model is read a second time, then updated with the changed values, and saved.

Am I understanding that correctly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions