1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #24846 -- Added support to MySQL SchemaEditor for all blob/text data types

This commit is contained in:
Adam Chainz
2015-05-24 11:16:21 +01:00
committed by Tim Graham
parent 00e8e514e1
commit e60cce4e40
4 changed files with 40 additions and 4 deletions

View File

@@ -34,10 +34,17 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
def skip_default(self, field):
"""
MySQL doesn't accept default values for longtext and longblob
and implicitly treats these columns as nullable.
MySQL doesn't accept default values for TEXT and BLOB types, and
implicitly treats these columns as nullable.
"""
return field.db_type(self.connection) in {'longtext', 'longblob'}
db_type = field.db_type(self.connection)
return (
db_type is not None and
db_type.lower() in {
'tinyblob', 'blob', 'mediumblob', 'longblob',
'tinytext', 'text', 'mediumtext', 'longtext',
}
)
def add_field(self, model, field):
super(DatabaseSchemaEditor, self).add_field(model, field)