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/inspectdb | |
parent | 68ef274bc505cd44f305c03cbf84cf08826200a8 (diff) | |
download | django-78f163a4fb3937aca2e71786fbdd51a0ef39629e.tar.gz |
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/inspectdb')
-rw-r--r-- | tests/inspectdb/models.py | 8 | ||||
-rw-r--r-- | tests/inspectdb/tests.py | 18 |
2 files changed, 26 insertions, 0 deletions
diff --git a/tests/inspectdb/models.py b/tests/inspectdb/models.py index c07cd4def1..5db4d3bc73 100644 --- a/tests/inspectdb/models.py +++ b/tests/inspectdb/models.py @@ -132,3 +132,11 @@ class FuncUniqueConstraint(models.Model): ) ] required_db_features = {"supports_expression_indexes"} + + +class DbComment(models.Model): + rank = models.IntegerField(db_comment="'Rank' column comment") + + class Meta: + db_table_comment = "Custom table comment" + required_db_features = {"supports_comments"} diff --git a/tests/inspectdb/tests.py b/tests/inspectdb/tests.py index 7944e5f221..2f26814625 100644 --- a/tests/inspectdb/tests.py +++ b/tests/inspectdb/tests.py @@ -129,6 +129,24 @@ class InspectDBTestCase(TestCase): "null_json_field = models.JSONField(blank=True, null=True)", output ) + @skipUnlessDBFeature("supports_comments") + def test_db_comments(self): + out = StringIO() + call_command("inspectdb", "inspectdb_dbcomment", stdout=out) + output = out.getvalue() + integer_field_type = connection.features.introspected_field_types[ + "IntegerField" + ] + self.assertIn( + f"rank = models.{integer_field_type}(" + f"db_comment=\"'Rank' column comment\")", + output, + ) + self.assertIn( + " db_table_comment = 'Custom table comment'", + output, + ) + @skipUnlessDBFeature("supports_collation_on_charfield") @skipUnless(test_collation, "Language collations are not supported.") def test_char_field_db_collation(self): |