#35890: pre_save field in parent models are not called during update in
update_or_create
-------------------------------------+-------------------------------------
     Reporter:  Gagaro               |                    Owner:  (none)
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  dev
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

 * cc: Simon Charette, Florian Apolloner, Sarah Boyce (added)

Comment:

 I think we need someone else to chime in here to get a consensus before
 moving forward with either solution.

 The `Field.auto_now` pattern is a feature on its way out #22995 and as it
 doesn't play nicely with `update_fields` #22981 particularly in the
 context of `update_or_create` (#35014 and associated
 [https://forum.djangoproject.com/t/update-or-create-behavior/25944 forum
 discussion]).


 In your particular case, `Child.save(update_fields={...})`, won't update
 `"modified_at"` unless it's specified explicitly so your expectations are
 already broken for any direct or indirect (through third-party apps) usage
 of `save(update_fields)`; `update_or_create` is only a single instance of
 that.

 The changes made to handle local concrete fields in #32095
 ([https://github.com/django/django/pull/13526 original PR by Florian],
 [https://github.com/django/django/pull/16072 eventually merged changes by
 Sarah]) unfortunately it didn't cover this use case,
 [https://github.com/django/django/pull/13526#discussion_r503304168 even if
 it was pointed out as a point of ambiguity], as neither `Book` or
 `Publisher` are using MTI.

 > Why do you think it should be that way?

 From my perspective, given the intent #32095 was to avoid unnecessary
 field updates, performing MTI inherited tables updates when non of their
 fields are explicitly requested to be updated because they use a pattern
 meant to be deprecated is not the right approach.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35890#comment:6>
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 [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019325f01fce-16a0230a-8e67-4c12-9fbf-d7e7de449844-000000%40eu-central-1.amazonses.com.

Reply via email to