1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #19676 -- Supported 'self' foreign keys in inspectdb.

Thanks Georgy Kutsurua for the report and Simon Charette for the patch.
This commit is contained in:
Aymeric Augustin
2013-01-28 10:21:07 +01:00
parent f46d7314b5
commit c47fa3b481
3 changed files with 6 additions and 3 deletions

View File

@@ -31,6 +31,8 @@ class InspectDBTestCase(TestCase):
stdout=out)
output = out.getvalue()
error_message = "inspectdb generated an attribute name which is a python keyword"
# Recursive foreign keys should be set to 'self'
self.assertIn("parent = models.ForeignKey('self')", output)
self.assertNotIn("from = models.ForeignKey(InspectdbPeople)", output, msg=error_message)
# As InspectdbPeople model is defined after InspectdbMessage, it should be quoted
self.assertIn("from_field = models.ForeignKey('InspectdbPeople', db_column='from_id')",