#36207: refresh_from_db() doesn't refresh ForeignObject relations
-------------------------------------+-------------------------------------
     Reporter:  Jacob Walls          |                    Owner:  Gregory
                                     |  Mariani
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  5.2
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by Jacob Walls):

 > Because comment.user = None will set the value None

 But the test case I sketched doesn't save that change to the database, so
 my expectation was that `refresh_from_db()` would return the same thing
 that a fresh query would return. Or at least this was my expectation based
 on how `ForeignKey` works.

 > So if we set user_id to None, the relations are destroyed for a
 ForeignObject.

 If this is how ForeignObject is supposed to work, then I feel we need to
 document it, because from the composite PK guide that I linked it's not
 obvious. However my impression is that it's ''not'' supposed to work like
 `.add()`, which immediately alters data.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36207#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 [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/01070195342ac241-89dae5d3-b69b-46db-b035-44e20fd67864-000000%40eu-central-1.amazonses.com.

Reply via email to