Added test for Model._check_column_name_clashes().

This commit is contained in:
Hasan Ramezani 2018-11-17 21:24:48 +01:00 committed by Tim Graham
parent 405ec5b9c6
commit ec16588c27
1 changed files with 15 additions and 0 deletions

View File

@ -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):