Fixed #31411 -- Used RENAME COLUMN on MariaDB 10.5.2+.

This commit is contained in:
Hasan Ramezani 2020-04-01 21:20:01 +02:00 committed by Mariusz Felisiak
parent b1f88476db
commit 1fe3e24264
1 changed files with 6 additions and 2 deletions

View File

@ -13,8 +13,6 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
# No 'CASCADE' which works as a no-op in MySQL but is undocumented
sql_delete_column = "ALTER TABLE %(table)s DROP COLUMN %(column)s"
sql_rename_column = "ALTER TABLE %(table)s CHANGE %(old_column)s %(new_column)s %(type)s"
sql_delete_unique = "ALTER TABLE %(table)s DROP INDEX %(name)s"
sql_create_column_inline_fk = (
', ADD CONSTRAINT %(name)s FOREIGN KEY (%(column)s) '
@ -38,6 +36,12 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
return 'ALTER TABLE %(table)s DROP CONSTRAINT IF EXISTS %(name)s'
return 'ALTER TABLE %(table)s DROP CHECK %(name)s'
@property
def sql_rename_column(self):
if self.connection.mysql_is_mariadb and self.connection.mysql_version >= (10, 5, 2):
return super().sql_rename_column
return 'ALTER TABLE %(table)s CHANGE %(old_column)s %(new_column)s %(type)s'
def quote_value(self, value):
self.connection.ensure_connection()
if isinstance(value, str):