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