#31382: Silent failure when saving non-concrete field with update_fields
-----------------------------------------+------------------------
               Reporter:  Peter Law      |          Owner:  nobody
                   Type:  Uncategorized  |         Status:  new
              Component:  Uncategorized  |        Version:  2.2
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 If you have a non-concrete field which wraps a couple of concrete fields
 (a bit like `GenericForeignKey`, though my codebase doesn't uses this for
 compound data types rather than relations), then when you pass the name of
 that non-concrete field to
 `save(update_fields=('my_non_concrete_field',))`, the model will be saved
 '''without''' saving that field and yet no error will be emitted.

 I think that this could be because the check for the validity of the
 `update_fields` is done against `meta.fields`
 
(https://github.com/django/django/blob/5c8441a0b8787c14b45fb761550571baea48604e/django/db/models/base.py#L714-L737)
 while the later check for which fields to actually save is done using
 `meta.local_concrete_fields`
 
(https://github.com/django/django/blob/5c8441a0b8787c14b45fb761550571baea48604e/django/db/models/base.py#L838-L844).

 Ideally, I would like a way for a non-concrete field to be able to specify
 the underlying concrete fields which should be saved on its behalf. That's
 clearly rather complex though (and would likely have impacts beyond just
 `update_fields`) -- a simpler solution would be to error about this case
 so that the developer knows something is amis.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31382>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/053.e9405fba1be377b36847d402b0c3a6fa%40djangoproject.com.

Reply via email to