1
0
mirror of https://github.com/django/django.git synced 2025-10-26 07:06:08 +00:00

[1.8.x] Fixed #24578 -- Fixed crash with QuerySet.update() on FK to O2O fields.

Thanks Anssi Kääriäinen for review.

Backport of 10b4c010ab2cdaa6ba8bfaec3e3540299ea77be from master
This commit is contained in:
Tim Graham
2015-04-07 09:08:05 -04:00
parent d11e87bff5
commit b1dc128a03
3 changed files with 15 additions and 1 deletions

View File

@@ -468,3 +468,14 @@ class OneToOneTests(TestCase):
# refs #21563
self.assertFalse(hasattr(Director(), 'director'))
self.assertFalse(hasattr(School(), 'school'))
def test_update_one_to_one_pk(self):
p1 = Place.objects.create()
p2 = Place.objects.create()
r1 = Restaurant.objects.create(place=p1)
r2 = Restaurant.objects.create(place=p2)
w = Waiter.objects.create(restaurant=r1)
Waiter.objects.update(restaurant=r2)
w.refresh_from_db()
self.assertEqual(w.restaurant, r2)