mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #27676 -- Allowed BLOB/TEXT defaults on MariaDB 10.2.1+.
This commit is contained in:
committed by
Mariusz Felisiak
parent
8a281aa7fe
commit
7da6a28a44
@@ -130,9 +130,11 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
'UUIDField': 'char(32)',
|
||||
}
|
||||
|
||||
# For these columns, MySQL doesn't:
|
||||
# - accept default values and implicitly treats these columns as nullable
|
||||
# - support a database index
|
||||
# For these data types:
|
||||
# - MySQL and MariaDB < 10.2.1 don't accept default values and implicitly
|
||||
# treat them as nullable
|
||||
# - all versions of MySQL and MariaDB don't support full width database
|
||||
# indexes
|
||||
_limited_data_types = (
|
||||
'tinyblob', 'blob', 'mediumblob', 'longblob', 'tinytext', 'text',
|
||||
'mediumtext', 'longtext', 'json',
|
||||
|
||||
@@ -48,7 +48,16 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
|
||||
return db_type is not None and db_type.lower() in self.connection._limited_data_types
|
||||
|
||||
def skip_default(self, field):
|
||||
return self._is_limited_data_type(field)
|
||||
if not self._supports_limited_data_type_defaults:
|
||||
return self._is_limited_data_type(field)
|
||||
return False
|
||||
|
||||
@property
|
||||
def _supports_limited_data_type_defaults(self):
|
||||
# Only MariaDB >= 10.2.1 supports defaults for BLOB and TEXT.
|
||||
if self.connection.mysql_is_mariadb:
|
||||
return self.connection.mysql_version >= (10, 2, 1)
|
||||
return False
|
||||
|
||||
def add_field(self, model, field):
|
||||
super().add_field(model, field)
|
||||
|
||||
Reference in New Issue
Block a user