summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Krönke <tobias@kroenke.de>2023-11-28 15:06:06 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-12-14 10:59:25 +0100
commitd6c868a184e01f44302e8d31130fe1321208a6af (patch)
tree4ca8f5e46a1e725ebe91537dd86706155db07af6
parent4b7fe146ccf6c3fa041f3b43099c93a68e78be96 (diff)
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.
-rw-r--r--django/db/backends/mysql/schema.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/django/db/backends/mysql/schema.py b/django/db/backends/mysql/schema.py
index 905a26bfba..8651348ee2 100644
--- a/django/db/backends/mysql/schema.py
+++ b/django/db/backends/mysql/schema.py
@@ -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.