Fixed #35000 -- Skipped declaring empty string defaults on BLOB/TEXT field on MySQL.

Empty string defaults are redundant on MySQL and prevent use of
ALGORITHM=INSTANT.
This commit is contained in:
Tobias Krönke 2023-11-28 15:06:06 +01:00 committed by Mariusz Felisiak
parent 4b7fe146cc
commit d6c868a184
1 changed files with 10 additions and 0 deletions

View File

@ -69,12 +69,22 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
and db_type.lower() in self.connection._limited_data_types
)
def _is_text_or_blob(self, field):
db_type = field.db_type(self.connection)
return db_type and db_type.lower().endswith(("blob", "text"))
def skip_default(self, field):
default_is_empty = self.effective_default(field) in ("", b"")
if default_is_empty and self._is_text_or_blob(field):
return True
if not self._supports_limited_data_type_defaults:
return self._is_limited_data_type(field)
return False
def skip_default_on_alter(self, field):
default_is_empty = self.effective_default(field) in ("", b"")
if default_is_empty and self._is_text_or_blob(field):
return True
if self._is_limited_data_type(field) and not self.connection.mysql_is_mariadb:
# MySQL doesn't support defaults for BLOB and TEXT in the
# ALTER COLUMN statement.