Skip to content

Commit

Permalink
Added test for Model._check_column_name_clashes().
Browse files Browse the repository at this point in the history
  • Loading branch information
hramezani authored and timgraham committed Nov 17, 2018
1 parent 405ec5b commit ec16588
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/invalid_models_tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,21 @@ class Model(models.Model):
)
])

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):
Expand Down

0 comments on commit ec16588

Please sign in to comment.