Added test for Model._check_column_name_clashes().
This commit is contained in:
parent
405ec5b9c6
commit
ec16588c27
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue