Fixed #23679 -- Fixed null introspection for char/text fields
Thanks Paul Dejean for the report.
This commit is contained in:
parent
2118aa8aea
commit
4fe6824ffd
|
@ -123,8 +123,7 @@ class Command(BaseCommand):
|
||||||
field_type = 'NullBooleanField('
|
field_type = 'NullBooleanField('
|
||||||
else:
|
else:
|
||||||
extra_params['blank'] = True
|
extra_params['blank'] = True
|
||||||
if field_type not in ('TextField(', 'CharField('):
|
extra_params['null'] = True
|
||||||
extra_params['null'] = True
|
|
||||||
|
|
||||||
field_desc = '%s = %s%s' % (
|
field_desc = '%s = %s%s' % (
|
||||||
att_name,
|
att_name,
|
||||||
|
|
|
@ -50,6 +50,7 @@ class ColumnTypes(models.Model):
|
||||||
bool_field = models.BooleanField(default=False)
|
bool_field = models.BooleanField(default=False)
|
||||||
null_bool_field = models.NullBooleanField()
|
null_bool_field = models.NullBooleanField()
|
||||||
char_field = models.CharField(max_length=10)
|
char_field = models.CharField(max_length=10)
|
||||||
|
null_char_field = models.CharField(max_length=10, blank=True, null=True)
|
||||||
comma_separated_int_field = models.CommaSeparatedIntegerField(max_length=99)
|
comma_separated_int_field = models.CommaSeparatedIntegerField(max_length=99)
|
||||||
date_field = models.DateField()
|
date_field = models.DateField()
|
||||||
date_time_field = models.DateTimeField()
|
date_time_field = models.DateTimeField()
|
||||||
|
|
|
@ -51,6 +51,7 @@ class InspectDBTestCase(TestCase):
|
||||||
if (connection.features.can_introspect_max_length and
|
if (connection.features.can_introspect_max_length and
|
||||||
not connection.features.interprets_empty_strings_as_nulls):
|
not connection.features.interprets_empty_strings_as_nulls):
|
||||||
assertFieldType('char_field', "models.CharField(max_length=10)")
|
assertFieldType('char_field', "models.CharField(max_length=10)")
|
||||||
|
assertFieldType('null_char_field', "models.CharField(max_length=10, blank=True, null=True)")
|
||||||
assertFieldType('comma_separated_int_field', "models.CharField(max_length=99)")
|
assertFieldType('comma_separated_int_field', "models.CharField(max_length=99)")
|
||||||
assertFieldType('date_field', "models.DateField()")
|
assertFieldType('date_field', "models.DateField()")
|
||||||
assertFieldType('date_time_field', "models.DateTimeField()")
|
assertFieldType('date_time_field', "models.DateTimeField()")
|
||||||
|
|
Loading…
Reference in New Issue