diff options
| author | saJaeHyukc <wogur981208@gmail.com> | 2025-02-22 18:47:03 +0900 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2025-02-22 18:14:37 +0100 |
| commit | f7017db92cee1536c014710f475a613792c1e4b5 (patch) | |
| tree | 38265b34b477a6da2b423c718b65a8837b2df0bc /tests/schema | |
| parent | 87c5de3b7f2316aa17353d74f54e6ff19013d049 (diff) | |
Fixed #35839 -- Fixed crash when adding GeneratedField with db_comment on MySQL.
Thanks Simon Charette for the test.
Signed-off-by: saJaeHyukc <wogur981208@gmail.com>
Diffstat (limited to 'tests/schema')
| -rw-r--r-- | tests/schema/tests.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/schema/tests.py b/tests/schema/tests.py index c0c284672b..f734525dcc 100644 --- a/tests/schema/tests.py +++ b/tests/schema/tests.py @@ -4861,6 +4861,24 @@ class SchemaTests(TransactionTestCase): comment, ) + @skipUnlessDBFeature("supports_comments", "supports_stored_generated_columns") + def test_add_db_comment_generated_field(self): + comment = "Custom comment" + field = GeneratedField( + expression=Value(1), + db_persist=True, + output_field=IntegerField(), + db_comment=comment, + ) + field.set_attributes_from_name("volume") + with connection.schema_editor() as editor: + editor.create_model(Author) + editor.add_field(Author, field) + self.assertEqual( + self.get_column_comment(Author._meta.db_table, "volume"), + comment, + ) + @skipUnlessDBFeature("supports_comments") def test_add_db_comment_and_default_charfield(self): comment = "Custom comment with default" |
