I would like to change the implementation of .save(). In the following case:
s = SomeModel.objects.get(pk=somepk) s.somefield = val s.save() we currently do this: SELECT (from .get()) SELECT (from .save()) UPDATE The second SELECT is redundant. We have knowledge that the model was loaded from the same DB in s._state. So, we could instead do just: SELECT (from .get()) UPDATE If the UPDATE doesn't match anything (due to concurrent delete for example), then we can still do an INSERT. So, from user perspective the behaviour isn't changed. The force_update flag isn't doing the exact same thing - when using force_update and the UPDATE doesn't change anything the INSERT isn't done, instead an error is risen. In most UPDATE situations this should reduce one SELECT from model.save(). The only problem I can see is that we have very explicitly documented how .save() behaves. The generated queries are documented. I don't consider the generated queries part of the publlic API, just the behaviour. All tests on all core backends do pass using the "UPDATE, if not updated INSERT" behaviour. See ticket #16649 for patch & details. Any objections moving forward with this plan? - Anssi -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
