mirror of
https://github.com/django/django.git
synced 2025-08-03 02:23:12 +00:00
Fixed #7190 -- Corrected a problem with Boolean value handling on the MySQL backend. Thanks to George Vilches for the initial patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12900 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
2fa2cf0a09
commit
271bcda04a
4 changed files with 62 additions and 2 deletions
|
@ -6,7 +6,7 @@ from django import forms
|
|||
from django.db import models
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
from models import Foo, Bar, Whiz, BigD, BigS, Image, BigInt, Post, NullBooleanModel
|
||||
from models import Foo, Bar, Whiz, BigD, BigS, Image, BigInt, Post, NullBooleanModel, BooleanModel
|
||||
|
||||
try:
|
||||
from decimal import Decimal
|
||||
|
@ -44,7 +44,7 @@ class BasicFieldTests(django.test.TestCase):
|
|||
"""
|
||||
Regression test for #13071: NullBooleanField should not throw
|
||||
a validation error when given a value of None.
|
||||
|
||||
|
||||
"""
|
||||
nullboolean = NullBooleanModel(nbfield=None)
|
||||
try:
|
||||
|
@ -162,6 +162,35 @@ class BooleanFieldTests(unittest.TestCase):
|
|||
f = models.BooleanField(choices=choices, default=1, null=False)
|
||||
self.assertEqual(f.formfield().choices, choices)
|
||||
|
||||
def test_return_type(self):
|
||||
b = BooleanModel()
|
||||
b.bfield = True
|
||||
b.save()
|
||||
b2 = BooleanModel.objects.get(pk=b.pk)
|
||||
self.assertTrue(isinstance(b2.bfield, bool))
|
||||
self.assertEqual(b2.bfield, True)
|
||||
|
||||
b3 = BooleanModel()
|
||||
b3.bfield = False
|
||||
b3.save()
|
||||
b4 = BooleanModel.objects.get(pk=b3.pk)
|
||||
self.assertTrue(isinstance(b4.bfield, bool))
|
||||
self.assertEqual(b4.bfield, False)
|
||||
|
||||
b = NullBooleanModel()
|
||||
b.nbfield = True
|
||||
b.save()
|
||||
b2 = NullBooleanModel.objects.get(pk=b.pk)
|
||||
self.assertTrue(isinstance(b2.nbfield, bool))
|
||||
self.assertEqual(b2.nbfield, True)
|
||||
|
||||
b3 = NullBooleanModel()
|
||||
b3.nbfield = False
|
||||
b3.save()
|
||||
b4 = NullBooleanModel.objects.get(pk=b3.pk)
|
||||
self.assertTrue(isinstance(b4.nbfield, bool))
|
||||
self.assertEqual(b4.nbfield, False)
|
||||
|
||||
class ChoicesTests(django.test.TestCase):
|
||||
def test_choices_and_field_display(self):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue