1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

Fixed #23679 -- Fixed null introspection for char/text fields

Thanks Paul Dejean for the report.
This commit is contained in:
Claude Paroz 2014-10-20 20:05:43 +02:00
parent 2118aa8aea
commit 4fe6824ffd
3 changed files with 3 additions and 2 deletions

View File

@ -123,8 +123,7 @@ class Command(BaseCommand):
field_type = 'NullBooleanField('
else:
extra_params['blank'] = True
if field_type not in ('TextField(', 'CharField('):
extra_params['null'] = True
extra_params['null'] = True
field_desc = '%s = %s%s' % (
att_name,

View File

@ -50,6 +50,7 @@ class ColumnTypes(models.Model):
bool_field = models.BooleanField(default=False)
null_bool_field = models.NullBooleanField()
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)
date_field = models.DateField()
date_time_field = models.DateTimeField()

View File

@ -51,6 +51,7 @@ class InspectDBTestCase(TestCase):
if (connection.features.can_introspect_max_length and
not connection.features.interprets_empty_strings_as_nulls):
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('date_field', "models.DateField()")
assertFieldType('date_time_field', "models.DateTimeField()")