Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tests/_utils/setup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -429,3 +429,13 @@ CREATE TABLE `contenttypes_tests_modelwithm2mtosite_site` (
KEY (`modelwithm2mtosite_id`),
KEY (`site_id`)
);

--test_runner
CREATE TABLE `test_runner_person_friend` (
`from_person_id` BIGINT NOT NULL,
`to_person_id` BIGINT NOT NULL,
SHARD KEY (`from_person_id`),
UNIQUE KEY (`from_person_id`, `to_person_id`),
KEY (`from_person_id`),
KEY (`to_person_id`)
);
14 changes: 13 additions & 1 deletion tests/test_runner/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@
class Person(models.Model):
first_name = models.CharField(max_length=20)
last_name = models.CharField(max_length=20)
friends = models.ManyToManyField("self")
friends = models.ManyToManyField("self", through="PersonFriend")

class PersonFriend(models.Model):
from_person = models.ForeignKey(
Person, on_delete=models.CASCADE, related_name="from_person"
)
to_person = models.ForeignKey(
Person, on_delete=models.CASCADE, related_name="to_person"
)

class Meta:
unique_together = (('from_person', 'to_person'),)
db_table = "test_runner_person_friend"


# A set of models that use a non-abstract inherited 'through' model.
Expand Down
Loading