Changes between Initial Version and Version 2 of Ticket #28702


Ignore:
Timestamp:
Oct 12, 2017, 9:42:31 AM (7 years ago)
Author:
Дилян Палаузов
Comment:

I agree that overriding _alter_column_null_sql() makes no sense and have removed it from the description.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #28702

    • Property Cc Mads Jensen added
    • Property Needs tests set
  • Ticket #28702 – Description

    initial v2  
    4343             index_name = self._create_index_name(model._meta.db_table, [old_field.column], suffix='_like')
    4444             self.execute(self._delete_constraint_sql(self.sql_delete_index, model, index_name))
    45 @@ -131,3 +132,11 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
    46          if old_field.unique and not (new_field.db_index or new_field.unique):
    47              index_to_remove = self._create_index_name(model._meta.db_table, [old_field.column], suffix='_like')
    48              self.execute(self._delete_constraint_sql(self.sql_delete_index, model, index_to_remove))
    49 +
    50 +
    51 +    def _alter_column_null_sql(self, model, old_field, new_field):
    52 +        if (self.connection.features.interprets_empty_strings_as_nulls and
    53 +                new_field.get_internal_type() in ("CICharField", "CITextField")):
    54 +            # The field is nullable in the database anyway, leave it alone.
    55 +            return
    56 +        return super()._alter_column_null_sql(model, old_field, new_field
    5745}}}
Back to Top