summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJulien Phalip <jphalip@gmail.com>2012-02-05 07:51:37 +0000
committerJulien Phalip <jphalip@gmail.com>2012-02-05 07:51:37 +0000
commitad8ebb7006be7d93f1c6a29770dbca2752488a62 (patch)
tree1d6a0427c3e4109a1cba565e28b020efffcdc8d5 /tests
parentd02ba7f4ee7c448de28724369fc5dd9cf3e2538a (diff)
Fixed #8317 -- Corrected the inspectdb management command to properly set `primary_key=True` and `unique=True` on foreign keys. Thanks to bthomas for the report and patch, and to David Gouldin for the tests.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17451 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/inspectdb/models.py9
-rw-r--r--tests/regressiontests/inspectdb/tests.py4
2 files changed, 13 insertions, 0 deletions
diff --git a/tests/regressiontests/inspectdb/models.py b/tests/regressiontests/inspectdb/models.py
index fc2548b441..fac47aa34f 100644
--- a/tests/regressiontests/inspectdb/models.py
+++ b/tests/regressiontests/inspectdb/models.py
@@ -6,3 +6,12 @@ class People(models.Model):
class Message(models.Model):
from_field = models.ForeignKey(People, db_column='from_id')
+
+class PeopleData(models.Model):
+ people_pk = models.ForeignKey(People, primary_key=True)
+ ssn = models.CharField(max_length=11)
+
+class PeopleMoreData(models.Model):
+ people_unique = models.ForeignKey(People, unique=True)
+ license = models.CharField(max_length=255)
+
diff --git a/tests/regressiontests/inspectdb/tests.py b/tests/regressiontests/inspectdb/tests.py
index 683e6e9cf7..e2eced576d 100644
--- a/tests/regressiontests/inspectdb/tests.py
+++ b/tests/regressiontests/inspectdb/tests.py
@@ -13,4 +13,8 @@ class InspectDBTestCase(TestCase):
error_message = "inspectdb generated an attribute name which is a python keyword"
self.assertNotIn("from = models.ForeignKey(InspectdbPeople)", out.getvalue(), msg=error_message)
self.assertIn("from_field = models.ForeignKey(InspectdbPeople)", out.getvalue())
+ self.assertIn("people_pk = models.ForeignKey(InspectdbPeople, primary_key=True)",
+ out.getvalue())
+ self.assertIn("people_unique = models.ForeignKey(InspectdbPeople, unique=True)",
+ out.getvalue())
out.close()