summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/many_to_many/tests.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/many_to_many/tests.py b/tests/many_to_many/tests.py
index 79d0fa420c..b4314580ec 100644
--- a/tests/many_to_many/tests.py
+++ b/tests/many_to_many/tests.py
@@ -469,6 +469,19 @@ class ManyToManyTests(TestCase):
self.a4.publications.set([], clear=True)
self.assertQuerysetEqual(self.a4.publications.all(), [])
+ def test_set_existing_different_type(self):
+ # Existing many-to-many relations remain the same for values provided
+ # with a different type.
+ ids = set(Publication.article_set.through.objects.filter(
+ article__in=[self.a4, self.a3],
+ publication=self.p2,
+ ).values_list('id', flat=True))
+ self.p2.article_set.set([str(self.a4.pk), str(self.a3.pk)])
+ new_ids = set(Publication.article_set.through.objects.filter(
+ publication=self.p2,
+ ).values_list('id', flat=True))
+ self.assertEqual(ids, new_ids)
+
def test_assign_forward(self):
msg = (
"Direct assignment to the reverse side of a many-to-many set is "