mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
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
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user