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_ordinary_fields.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_ordinary_fields.py')
| -rw-r--r-- | tests/invalid_models_tests/test_ordinary_fields.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/invalid_models_tests/test_ordinary_fields.py b/tests/invalid_models_tests/test_ordinary_fields.py index ef7f845a33..4e07c95956 100644 --- a/tests/invalid_models_tests/test_ordinary_fields.py +++ b/tests/invalid_models_tests/test_ordinary_fields.py @@ -1023,3 +1023,35 @@ class JSONFieldTests(TestCase): field = models.JSONField(default=callable_default) self.assertEqual(Model._meta.get_field("field").check(), []) + + +@isolate_apps("invalid_models_tests") +class DbCommentTests(TestCase): + def test_db_comment(self): + class Model(models.Model): + field = models.IntegerField(db_comment="Column comment") + + errors = Model._meta.get_field("field").check(databases=self.databases) + expected = ( + [] + if connection.features.supports_comments + else [ + DjangoWarning( + f"{connection.display_name} does not support comments on columns " + f"(db_comment).", + obj=Model._meta.get_field("field"), + id="fields.W163", + ), + ] + ) + self.assertEqual(errors, expected) + + def test_db_comment_required_db_features(self): + class Model(models.Model): + field = models.IntegerField(db_comment="Column comment") + + class Meta: + required_db_features = {"supports_comments"} + + errors = Model._meta.get_field("field").check(databases=self.databases) + self.assertEqual(errors, []) |
