mirror of
https://github.com/django/django.git
synced 2025-04-26 02:04:38 +00:00
Fixed #35006 -- Fixed migrations crash when altering Meta.db_table_comment on SQLite.
Thanks Юрий for the report. Regression in 78f163a4fb3937aca2e71786fbdd51a0ef39629e.
This commit is contained in:
parent
57c1dd466f
commit
37fc832a54
@ -670,6 +670,7 @@ class BaseDatabaseSchemaEditor:
|
|||||||
sql.rename_table_references(old_db_table, new_db_table)
|
sql.rename_table_references(old_db_table, new_db_table)
|
||||||
|
|
||||||
def alter_db_table_comment(self, model, old_db_table_comment, new_db_table_comment):
|
def alter_db_table_comment(self, model, old_db_table_comment, new_db_table_comment):
|
||||||
|
if self.sql_alter_table_comment and self.connection.features.supports_comments:
|
||||||
self.execute(
|
self.execute(
|
||||||
self.sql_alter_table_comment
|
self.sql_alter_table_comment
|
||||||
% {
|
% {
|
||||||
|
@ -19,6 +19,8 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
|
|||||||
sql_delete_column = "ALTER TABLE %(table)s DROP COLUMN %(column)s"
|
sql_delete_column = "ALTER TABLE %(table)s DROP COLUMN %(column)s"
|
||||||
sql_create_unique = "CREATE UNIQUE INDEX %(name)s ON %(table)s (%(columns)s)"
|
sql_create_unique = "CREATE UNIQUE INDEX %(name)s ON %(table)s (%(columns)s)"
|
||||||
sql_delete_unique = "DROP INDEX %(name)s"
|
sql_delete_unique = "DROP INDEX %(name)s"
|
||||||
|
sql_alter_table_comment = None
|
||||||
|
sql_alter_column_comment = None
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
# Some SQLite schema alterations need foreign key constraints to be
|
# Some SQLite schema alterations need foreign key constraints to be
|
||||||
|
@ -35,3 +35,6 @@ Bugfixes
|
|||||||
* Fixed a regression in Django 4.2 where the admin's read-only password widget
|
* Fixed a regression in Django 4.2 where the admin's read-only password widget
|
||||||
and some help texts were incorrectly aligned at tablet widths
|
and some help texts were incorrectly aligned at tablet widths
|
||||||
(:ticket:`34982`).
|
(:ticket:`34982`).
|
||||||
|
|
||||||
|
* Fixed a regression in Django 4.2 that caused a migration crash on SQLite when
|
||||||
|
altering unsupported ``Meta.db_table_comment`` (:ticket:`35006`).
|
||||||
|
@ -4741,6 +4741,23 @@ class SchemaTests(TransactionTestCase):
|
|||||||
[None, ""],
|
[None, ""],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@isolate_apps("schema")
|
||||||
|
@skipIfDBFeature("supports_comments")
|
||||||
|
def test_db_comment_table_unsupported(self):
|
||||||
|
class ModelWithDbTableComment(Model):
|
||||||
|
class Meta:
|
||||||
|
app_label = "schema"
|
||||||
|
db_table_comment = "Custom table comment"
|
||||||
|
|
||||||
|
# Table comments are ignored on databases that don't support them.
|
||||||
|
with connection.schema_editor() as editor, self.assertNumQueries(1):
|
||||||
|
editor.create_model(ModelWithDbTableComment)
|
||||||
|
self.isolated_local_models = [ModelWithDbTableComment]
|
||||||
|
with connection.schema_editor() as editor, self.assertNumQueries(0):
|
||||||
|
editor.alter_db_table_comment(
|
||||||
|
ModelWithDbTableComment, "Custom table comment", "New table comment"
|
||||||
|
)
|
||||||
|
|
||||||
@isolate_apps("schema")
|
@isolate_apps("schema")
|
||||||
@skipUnlessDBFeature("supports_comments", "supports_foreign_keys")
|
@skipUnlessDBFeature("supports_comments", "supports_foreign_keys")
|
||||||
def test_db_comments_from_abstract_model(self):
|
def test_db_comments_from_abstract_model(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user