mirror of https://github.com/django/django.git
Fixed #19341 -- Detected NullBooleanField when introspecting models
Thanks Tim Bowden for the report.
This commit is contained in:
parent
3c0a81aaf0
commit
7bbd17bf20
|
@ -108,9 +108,12 @@ class Command(NoArgsCommand):
|
|||
# Add 'null' and 'blank', if the 'null_ok' flag was present in the
|
||||
# table description.
|
||||
if row[6]: # If it's NULL...
|
||||
extra_params['blank'] = True
|
||||
if not field_type in ('TextField(', 'CharField('):
|
||||
extra_params['null'] = True
|
||||
if field_type == 'BooleanField(':
|
||||
field_type = 'NullBooleanField('
|
||||
else:
|
||||
extra_params['blank'] = True
|
||||
if not field_type in ('TextField(', 'CharField('):
|
||||
extra_params['null'] = True
|
||||
|
||||
field_desc = '%s = models.%s' % (att_name, field_type)
|
||||
if extra_params:
|
||||
|
|
|
@ -34,6 +34,7 @@ class ColumnTypes(models.Model):
|
|||
id = models.AutoField(primary_key=True)
|
||||
field1 = models.BigIntegerField()
|
||||
field2 = models.BooleanField()
|
||||
field2b = models.NullBooleanField()
|
||||
field3 = models.CharField(max_length=10)
|
||||
field4 = models.CommaSeparatedIntegerField(max_length=99)
|
||||
field5 = models.DateField()
|
||||
|
@ -46,7 +47,6 @@ class ColumnTypes(models.Model):
|
|||
field12 = models.IntegerField()
|
||||
field13 = models.IPAddressField()
|
||||
field14 = models.GenericIPAddressField(protocol="ipv4")
|
||||
field15 = models.NullBooleanField()
|
||||
field16 = models.PositiveIntegerField()
|
||||
field17 = models.PositiveSmallIntegerField()
|
||||
field18 = models.SlugField()
|
||||
|
|
|
@ -39,8 +39,10 @@ class InspectDBTestCase(TestCase):
|
|||
if connection.vendor == 'mysql':
|
||||
# No native boolean type on MySQL
|
||||
assertFieldType('field2', "models.IntegerField()")
|
||||
assertFieldType('field2b', "models.IntegerField(null=True, blank=True)")
|
||||
else:
|
||||
assertFieldType('field2', "models.BooleanField()")
|
||||
assertFieldType('field2b', "models.NullBooleanField()")
|
||||
assertFieldType('field3', "models.CharField(max_length=10)")
|
||||
# CommaSeparatedIntegerField
|
||||
assertFieldType('field4', "models.CharField(max_length=99)")
|
||||
|
@ -68,8 +70,6 @@ class InspectDBTestCase(TestCase):
|
|||
else:
|
||||
assertFieldType('field13', "models.CharField(max_length=15)")
|
||||
assertFieldType('field14', "models.CharField(max_length=39)")
|
||||
# Ticket #19341
|
||||
#assertFieldType('field15', "models.NullBooleanField()")
|
||||
if connection.vendor == 'sqlite':
|
||||
assertFieldType('field16', "models.PositiveIntegerField()")
|
||||
assertFieldType('field17', "models.PositiveSmallIntegerField()")
|
||||
|
|
Loading…
Reference in New Issue