#36847: FileField(upload_to=...) callback no longer sees `auto_now_add ` field
-------------------------------------+-------------------------------------
     Reporter:  Ran Benita           |                    Owner:  Nashrh
                                     |  Ashraf Khan
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  6.0
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:  needsinfo
     Keywords:  upload_to,           |             Triage Stage:  Accepted
  auto_now_add, pre_save             |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):

 Thanks for the CC Jacob.

 We should definitely pass `add=True` as you pointed out for correctness
 reasons but given we discard the values if they are not expressions this
 seems more like a way to avoid subtle undefined behavior breakages that we
 can afford but it doesn't require too much gymnastics on our end.

 In other words, I believe that landing a patch here should be seen as a
 way to correctly invoke the saving machinery (we've historically called
 `pre_save` with `add=True`) over a long term commitment over model field
 definition order dictating attribute presence on model instances.

 For example, something else that subtly changed is that we now call
 `pre_save` twice (in `Model._save_table` and `SQLInsertCompiler.as_sql`)
 and is something that would require move invasive changes that flipping
 `add=True` to resolve.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36847#comment:10>
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/0107019b99e4e4c9-f948897d-29f1-4d51-af01-535e7e7198f1-000000%40eu-central-1.amazonses.com.

Reply via email to