summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVladimir Kochetkov <whysages@gmail.com>2022-07-04 21:28:44 +0300
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-07-06 09:35:50 +0200
commit3926e35aa8c947b4c87aea33546b2e45347eaaa3 (patch)
tree3ab712e1d75b392f0e9aa6f8f27a28d01e9faa01 /tests
parent877c800f255ccaa7abde1fb944de45d1616f5cc9 (diff)
Fixed #33823 -- Made inspectdb generate unique related_name when reverse accessor clashes.
Diffstat (limited to 'tests')
-rw-r--r--tests/inspectdb/models.py1
-rw-r--r--tests/inspectdb/tests.py9
2 files changed, 10 insertions, 0 deletions
diff --git a/tests/inspectdb/models.py b/tests/inspectdb/models.py
index 4227299b94..c07cd4def1 100644
--- a/tests/inspectdb/models.py
+++ b/tests/inspectdb/models.py
@@ -9,6 +9,7 @@ class People(models.Model):
class Message(models.Model):
from_field = models.ForeignKey(People, models.CASCADE, db_column="from_id")
+ author = models.ForeignKey(People, models.CASCADE, related_name="message_authors")
class PeopleData(models.Model):
diff --git a/tests/inspectdb/tests.py b/tests/inspectdb/tests.py
index 9bf3c432e5..66b2eb8260 100644
--- a/tests/inspectdb/tests.py
+++ b/tests/inspectdb/tests.py
@@ -433,6 +433,15 @@ class InspectDBTestCase(TestCase):
# The error message depends on the backend
self.assertIn("# The error was:", output)
+ def test_same_relations(self):
+ out = StringIO()
+ call_command("inspectdb", "inspectdb_message", stdout=out)
+ self.assertIn(
+ "author = models.ForeignKey('InspectdbPeople', models.DO_NOTHING, "
+ "related_name='inspectdbmessage_author_set')",
+ out.getvalue(),
+ )
+
class InspectDBTransactionalTests(TransactionTestCase):
available_apps = ["inspectdb"]