summaryrefslogtreecommitdiff
path: root/tests/invalid_models_tests
diff options
context:
space:
mode:
authorHasan Ramezani <hasan.r67@gmail.com>2018-11-17 21:24:48 +0100
committerTim Graham <timograham@gmail.com>2018-11-17 15:24:48 -0500
commitec16588c27f7ea80d5ee3d5b19331ef9216e2530 (patch)
tree3394c48c7d7cfb1973bb91bf657fa3186f3bc99a /tests/invalid_models_tests
parent405ec5b9c6996bf4e5fba68a9bad76d17e146327 (diff)
Added test for Model._check_column_name_clashes().
Diffstat (limited to 'tests/invalid_models_tests')
-rw-r--r--tests/invalid_models_tests/test_models.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py
index 6ab13f18db..5b7042e127 100644
--- a/tests/invalid_models_tests/test_models.py
+++ b/tests/invalid_models_tests/test_models.py
@@ -421,6 +421,21 @@ class FieldNamesTests(SimpleTestCase):
)
])
+ def test_db_column_clash(self):
+ class Model(models.Model):
+ foo = models.IntegerField()
+ bar = models.IntegerField(db_column='foo')
+
+ self.assertEqual(Model.check(), [
+ Error(
+ "Field 'bar' has column name 'foo' that is used by "
+ "another field.",
+ hint="Specify a 'db_column' for the field.",
+ obj=Model,
+ id='models.E007',
+ )
+ ])
+
@isolate_apps('invalid_models_tests')
class ShadowingFieldsTests(SimpleTestCase):