#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: 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 Sarah Boyce):
* cc: Csirmaz Bendegúz, Lily Foote (added)
* severity: Release blocker => Normal
Comment:
This also fails on Django 5.1
{{{#!diff
--- a/tests/foreign_object/tests.py
+++ b/tests/foreign_object/tests.py
@@ -437,6 +437,15 @@ class MultiColumnFKTests(TestCase):
normal_groups_lists = [list(p.groups.all()) for p in
Person.objects.all()]
self.assertEqual(groups_lists, normal_groups_lists)
+ def test_refresh_foreign_object(self):
+ member = Membership.objects.create(
+ membership_country=self.usa, person=self.bob, group_id=None
+ )
+ self.assertEqual(member.person, self.bob)
+ member.person = None
+ member.refresh_from_db()
+ self.assertEqual(member.person, self.bob)
+
@translation.override("fi")
def test_translations(self):
a1 = Article.objects.create(pub_date=datetime.date.today())
}}}
We documented that this is an internal API, and therefore not supported by
our deprecation policy.
I don't think this is supported by our "new feature in 5.2" policy of back
porting bug fixes. I am therefore demoting this from a release blocker to
"normal".
If this note implies this should work "perfectly", we should remove the
suggestion to use `ForeignObject`.
#35956 aims to add ForeignKey support.
--
Ticket URL: <https://code.djangoproject.com/ticket/36207#comment:11>
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/01070195370d352b-44324c6e-df93-4520-9894-3e256e702cc1-000000%40eu-central-1.amazonses.com.