mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #21079 -- Further normalized table names in inspectdb
Thanks Michael Manfre for the report and Tim Graham for the review.
This commit is contained in:
parent
2572c07cc6
commit
b144bfb5ce
3 changed files with 20 additions and 3 deletions
|
@ -179,7 +179,9 @@ class InspectDBTestCase(TestCase):
|
|||
unsuitable for Python identifiers
|
||||
"""
|
||||
out = StringIO()
|
||||
call_command('inspectdb', stdout=out)
|
||||
call_command('inspectdb',
|
||||
table_name_filter=lambda tn: tn.startswith('inspectdb_'),
|
||||
stdout=out)
|
||||
output = out.getvalue()
|
||||
base_name = 'Field' if not connection.features.uppercases_column_names else 'field'
|
||||
self.assertIn("field = models.IntegerField()", output)
|
||||
|
@ -193,6 +195,18 @@ class InspectDBTestCase(TestCase):
|
|||
else:
|
||||
self.assertIn("tama_o = models.IntegerField(db_column='tama\\xf1o')", output)
|
||||
|
||||
def test_table_name_introspection(self):
|
||||
"""
|
||||
Introspection of table names containing special characters,
|
||||
unsuitable for Python identifiers
|
||||
"""
|
||||
out = StringIO()
|
||||
call_command('inspectdb',
|
||||
table_name_filter=lambda tn: tn.startswith('inspectdb_'),
|
||||
stdout=out)
|
||||
output = out.getvalue()
|
||||
self.assertIn("class InspectdbSpecialTableName(models.Model):", output)
|
||||
|
||||
def test_managed_models(self):
|
||||
"""Test that by default the command generates models with `Meta.managed = False` (#14305)"""
|
||||
out = StringIO()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue