summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-01-28 10:21:07 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-01-28 10:21:07 +0100
commitc47fa3b4814240bb47342a4446d40ea83bd3ed19 (patch)
tree5beed3ce7d9d0262bd6287a569ff0de35533f446 /tests
parentf46d7314b50d71a75f51ebae9c5957cb96b11bd9 (diff)
Fixed #19676 -- Supported 'self' foreign keys in inspectdb.
Thanks Georgy Kutsurua for the report and Simon Charette for the patch.
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/inspectdb/models.py1
-rw-r--r--tests/regressiontests/inspectdb/tests.py2
2 files changed, 3 insertions, 0 deletions
diff --git a/tests/regressiontests/inspectdb/models.py b/tests/regressiontests/inspectdb/models.py
index 4a6621402f..a8adf862b1 100644
--- a/tests/regressiontests/inspectdb/models.py
+++ b/tests/regressiontests/inspectdb/models.py
@@ -3,6 +3,7 @@ from django.db import models
class People(models.Model):
name = models.CharField(max_length=255)
+ parent = models.ForeignKey('self')
class Message(models.Model):
from_field = models.ForeignKey(People, db_column='from_id')
diff --git a/tests/regressiontests/inspectdb/tests.py b/tests/regressiontests/inspectdb/tests.py
index 028d263337..f9cbbce5c4 100644
--- a/tests/regressiontests/inspectdb/tests.py
+++ b/tests/regressiontests/inspectdb/tests.py
@@ -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')",