Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #11521 -- usage of field.attname in .update()

Fixed already by previous patch, only test added.
  • Loading branch information...
commit e01b5a5823fa06a63382f87472978a16c77048d2 1 parent c21e86a
Anssi Kääriäinen authored June 18, 2013

Showing 1 changed file with 11 additions and 2 deletions. Show diff stats Hide diff stats

  1. 13  tests/update/tests.py
13  tests/update/tests.py
@@ -2,7 +2,7 @@
2 2
 
3 3
 from django.test import TestCase
4 4
 
5  
-from .models import A, B, C, D, DataPoint, RelatedPoint
  5
+from .models import A, B, D, DataPoint, RelatedPoint
6 6
 
7 7
 
8 8
 class SimpleTest(TestCase):
@@ -51,6 +51,15 @@ def test_empty_update_with_inheritance(self):
51 51
         cnt = D.objects.filter(y=100).count()
52 52
         self.assertEqual(cnt, 0)
53 53
 
  54
+    def test_foreign_key_update_with_id(self):
  55
+        """
  56
+        Test that update works using <field>_id for foreign keys
  57
+        """
  58
+        num_updated = self.a1.d_set.update(a_id=self.a2)
  59
+        self.assertEqual(num_updated, 20)
  60
+        self.assertEqual(self.a2.d_set.count(), 20)
  61
+
  62
+
54 63
 class AdvancedTests(TestCase):
55 64
 
56 65
     def setUp(self):
@@ -115,4 +124,4 @@ def test_update_slice_fail(self):
115 124
         """
116 125
         method = DataPoint.objects.all()[:2].update
117 126
         self.assertRaises(AssertionError, method,
118  
-            another_value='another thing')
  127
+                          another_value='another thing')

0 notes on commit e01b5a5

Please sign in to comment.
Something went wrong with that request. Please try again.