diff options
| author | Karen Tracey <kmtracey@gmail.com> | 2011-11-12 19:06:39 +0000 |
|---|---|---|
| committer | Karen Tracey <kmtracey@gmail.com> | 2011-11-12 19:06:39 +0000 |
| commit | 63ba472cc4a0ce34d28af74d11e8037a1b3d0f96 (patch) | |
| tree | f6fafb1f8802f78464175b36f597a145375492cf /tests/modeltests/force_insert_update | |
| parent | eb81f979a8d794a2e2beef9b4d5255fd519c536b (diff) | |
Fix #13864: Removed database error raised when force_update is requsted on save of an inherited model with no fields of its own. Thanks fva, gregmuellegger, and markb1.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17088 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/modeltests/force_insert_update')
| -rw-r--r-- | tests/modeltests/force_insert_update/models.py | 10 | ||||
| -rw-r--r-- | tests/modeltests/force_insert_update/tests.py | 27 |
2 files changed, 35 insertions, 2 deletions
diff --git a/tests/modeltests/force_insert_update/models.py b/tests/modeltests/force_insert_update/models.py index db4c5d29f3..c356312606 100644 --- a/tests/modeltests/force_insert_update/models.py +++ b/tests/modeltests/force_insert_update/models.py @@ -9,6 +9,16 @@ class Counter(models.Model): name = models.CharField(max_length = 10) value = models.IntegerField() +class InheritedCounter(Counter): + tag = models.CharField(max_length=10) + +class ProxyCounter(Counter): + class Meta: + proxy = True + +class SubCounter(Counter): + pass + class WithCustomPK(models.Model): name = models.IntegerField(primary_key=True) value = models.IntegerField() diff --git a/tests/modeltests/force_insert_update/tests.py b/tests/modeltests/force_insert_update/tests.py index ea0e55f4c2..a5b2dcebb5 100644 --- a/tests/modeltests/force_insert_update/tests.py +++ b/tests/modeltests/force_insert_update/tests.py @@ -3,14 +3,15 @@ from __future__ import absolute_import from django.db import transaction, IntegrityError, DatabaseError from django.test import TestCase -from .models import Counter, WithCustomPK +from .models import (Counter, WithCustomPK, InheritedCounter, ProxyCounter, + SubCounter) class ForceTests(TestCase): def test_force_update(self): c = Counter.objects.create(name="one", value=1) - # The normal case + # The normal case c.value = 2 c.save() # Same thing, via an update @@ -38,3 +39,25 @@ class ForceTests(TestCase): # the data isn't in the database already. obj = WithCustomPK(name=1, value=1) self.assertRaises(DatabaseError, obj.save, force_update=True) + + +class InheritanceTests(TestCase): + def test_force_update_on_inherited_model(self): + a = InheritedCounter(name="count", value=1, tag="spam") + a.save() + a.save(force_update=True) + + def test_force_update_on_proxy_model(self): + a = ProxyCounter(name="count", value=1) + a.save() + a.save(force_update=True) + + def test_force_update_on_inherited_model_without_fields(self): + ''' + Issue 13864: force_update fails on subclassed models, if they don't + specify custom fields. + ''' + a = SubCounter(name="count", value=1) + a.save() + a.value = 2 + a.save(force_update=True) |
