mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
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>
This commit is contained in:
committed by
Mariusz Felisiak
parent
68ef274bc5
commit
78f163a4fb
@@ -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 = (
|
||||
|
||||
Reference in New Issue
Block a user