diff options
| author | Anssi Kääriäinen <akaariai@gmail.com> | 2013-06-18 21:15:13 +0300 |
|---|---|---|
| committer | Anssi Kääriäinen <akaariai@gmail.com> | 2013-07-31 16:02:36 +0300 |
| commit | e01b5a5823fa06a63382f87472978a16c77048d2 (patch) | |
| tree | d60ff5fd2c29c87b26b6149550604d7141edd3e0 /tests/update | |
| parent | c21e86ab9e3e5ebd6d245d038cb0cb352cd84c3a (diff) | |
Fixed #11521 -- usage of field.attname in .update()
Fixed already by previous patch, only test added.
Diffstat (limited to 'tests/update')
| -rw-r--r-- | tests/update/tests.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/update/tests.py b/tests/update/tests.py index 9db9625183..95e9069972 100644 --- a/tests/update/tests.py +++ b/tests/update/tests.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals from django.test import TestCase -from .models import A, B, C, D, DataPoint, RelatedPoint +from .models import A, B, D, DataPoint, RelatedPoint class SimpleTest(TestCase): @@ -51,6 +51,15 @@ class SimpleTest(TestCase): cnt = D.objects.filter(y=100).count() self.assertEqual(cnt, 0) + def test_foreign_key_update_with_id(self): + """ + Test that update works using <field>_id for foreign keys + """ + num_updated = self.a1.d_set.update(a_id=self.a2) + self.assertEqual(num_updated, 20) + self.assertEqual(self.a2.d_set.count(), 20) + + class AdvancedTests(TestCase): def setUp(self): @@ -115,4 +124,4 @@ class AdvancedTests(TestCase): """ method = DataPoint.objects.all()[:2].update self.assertRaises(AssertionError, method, - another_value='another thing') + another_value='another thing') |
