#36207: refresh_from_db() doesn't refresh ForeignObject relations
-------------------------------------+-------------------------------------
     Reporter:  Jacob Walls          |                    Owner:  (none)
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  5.2
  (models, ORM)                      |
     Severity:  Release blocker      |               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 Gregory Mariani):

 @Jacob
 Does this test is also correct with the logic you expect ?


 {{{
 def test_refresh_foreign_object(self):
     # Retrieve the comment via the DB to ensure from_db() is called and
 _original_pk is set
     comment = Comment.objects.get(pk=self.comment_1.pk)
     # Remove the underlying 'user_id' from __dict__ to simulate a cleared
 ForeignObject cache
     comment.__dict__.pop("user_id", None)
     # Call refresh_from_db() to reload the original values from the
 database
     comment.refresh_from_db()
     # Assert that refresh_from_db() has restored 'user' to its original
 value
     self.assertEqual(comment.user, self.user_1)
 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36207#comment:4>
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/0107019533898a8d-11f6ba17-bf6d-411b-b75e-e5fe2aab874e-000000%40eu-central-1.amazonses.com.

Reply via email to