From ec16588c27f7ea80d5ee3d5b19331ef9216e2530 Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Sat, 17 Nov 2018 21:24:48 +0100 Subject: [PATCH] Added test for Model._check_column_name_clashes(). --- tests/invalid_models_tests/test_models.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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):