(self)
| 5029 | |
| 5030 | @skipUnlessDBFeature("supports_comments") |
| 5031 | def test_add_db_comment_and_default_charfield(self): |
| 5032 | comment = "Custom comment with default" |
| 5033 | field = CharField(max_length=255, default="Joe Doe", db_comment=comment) |
| 5034 | field.set_attributes_from_name("name_with_comment_default") |
| 5035 | with connection.schema_editor() as editor: |
| 5036 | editor.create_model(Author) |
| 5037 | Author.objects.create(name="Before adding a new field") |
| 5038 | editor.add_field(Author, field) |
| 5039 | |
| 5040 | self.assertEqual( |
| 5041 | self.get_column_comment(Author._meta.db_table, "name_with_comment_default"), |
| 5042 | comment, |
| 5043 | ) |
| 5044 | with connection.cursor() as cursor: |
| 5045 | cursor.execute( |
| 5046 | f"SELECT name_with_comment_default FROM {Author._meta.db_table};" |
| 5047 | ) |
| 5048 | for row in cursor.fetchall(): |
| 5049 | self.assertEqual(row[0], "Joe Doe") |
| 5050 | |
| 5051 | @skipUnlessDBFeature("supports_comments") |
| 5052 | def test_alter_db_comment(self): |
nothing calls this directly
no test coverage detected