#28344: Add for_update parameter to Model.refresh_from_db() -------------------------------------+------------------------------------- Reporter: Patryk Zawadzki | Owner: (none) Type: New feature | Status: new Component: Database layer | Version: master (models, ORM) | Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by Patryk Zawadzki): Hugo, I appreciate your example but in my case I am dealing with financial transactions where I absolutely need to keep a database audit trail. This means I can't just wrap everything in a large transaction and risk it getting rolled back. Instead I have a number of tiny atomic blocks that need to be placed with surgical precision. This means I have to fetch the same object multiple times for it to act as the transaction synchronization point (via `SELECT FOR UPDATE` within each atomic block). Maybe it would be easier to introduce `transaction.atomic_with_locked(obj)` that would be the equivalent of: {{{ with transaction.atomic(): Foo.objects.select_for_update.get(pk=foo.pk) # discarding the result is fine as the lock is now in place yield }}} -- Ticket URL: <https://code.djangoproject.com/ticket/28344#comment:9> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.feb8b54e89d76ec4096d09bb2675562c%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.