Fixed #33187 -- Made inspectdb handle ForeignKey.to_field attribute.

This commit is contained in:
jordan.bae 2021-10-31 00:08:06 +09:00 committed by Mariusz Felisiak
parent dab48b7482
commit aaf9b55858
3 changed files with 22 additions and 2 deletions

View file

@ -204,6 +204,16 @@ class InspectDBTestCase(TestCase):
output,
)
@skipUnlessDBFeature('can_introspect_foreign_keys')
def test_foreign_key_to_field(self):
out = StringIO()
call_command('inspectdb', 'inspectdb_foreignkeytofield', stdout=out)
self.assertIn(
"to_field_fk = models.ForeignKey('InspectdbPeoplemoredata', "
"models.DO_NOTHING, to_field='people_unique_id')",
out.getvalue(),
)
def test_digits_column_name_introspection(self):
"""Introspection of column names consist/start with digits (#16536/#17676)"""
char_field_type = connection.features.introspected_field_types['CharField']