diff options
| author | kimsoungryoul <kimsoungryoul@gmail.com> | 2022-10-16 14:59:39 +0900 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-12-28 06:28:07 +0100 |
| commit | 78f163a4fb3937aca2e71786fbdd51a0ef39629e (patch) | |
| tree | 7e61c2f8d96b9dab60e317d3483460064327d701 /tests/invalid_models_tests/test_models.py | |
| parent | 68ef274bc505cd44f305c03cbf84cf08826200a8 (diff) | |
Fixed #18468 -- Added support for comments on columns and tables.
Thanks Jared Chung, Tom Carrick, David Smith, Nick Pope, and Mariusz
Felisiak for reviews.
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Co-authored-by: Nick Pope <nick@nickpope.me.uk>
Diffstat (limited to 'tests/invalid_models_tests/test_models.py')
| -rw-r--r-- | tests/invalid_models_tests/test_models.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py index 5a5aeccdf5..c07c83d79d 100644 --- a/tests/invalid_models_tests/test_models.py +++ b/tests/invalid_models_tests/test_models.py @@ -1872,6 +1872,37 @@ class OtherModelTests(SimpleTestCase): ) +@isolate_apps("invalid_models_tests") +class DbTableCommentTests(TestCase): + def test_db_table_comment(self): + class Model(models.Model): + class Meta: + db_table_comment = "Table comment" + + errors = Model.check(databases=self.databases) + expected = ( + [] + if connection.features.supports_comments + else [ + Warning( + f"{connection.display_name} does not support comments on tables " + f"(db_table_comment).", + obj=Model, + id="models.W046", + ), + ] + ) + self.assertEqual(errors, expected) + + def test_db_table_comment_required_db_features(self): + class Model(models.Model): + class Meta: + db_table_comment = "Table comment" + required_db_features = {"supports_comments"} + + self.assertEqual(Model.check(databases=self.databases), []) + + class MultipleAutoFieldsTests(TestCase): def test_multiple_autofields(self): msg = ( |
