diff options
Diffstat (limited to 'tests/many_to_many/tests.py')
-rw-r--r-- | tests/many_to_many/tests.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/many_to_many/tests.py b/tests/many_to_many/tests.py index a60ea42430..79d0fa420c 100644 --- a/tests/many_to_many/tests.py +++ b/tests/many_to_many/tests.py @@ -1,7 +1,7 @@ from unittest import mock from django.db import transaction -from django.test import TestCase, skipUnlessDBFeature +from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature from .models import ( Article, InheritedArticleA, InheritedArticleB, Publication, User, @@ -158,6 +158,14 @@ class ManyToManyTests(TestCase): with self.assertNumQueries(1): self.a1.publications.add(self.p1, self.p2) + @skipIfDBFeature('supports_ignore_conflicts') + def test_add_existing_different_type(self): + # A single SELECT query is necessary to compare existing values to the + # provided one; no INSERT should be attempted. + with self.assertNumQueries(1): + self.a1.publications.add(str(self.p1.pk)) + self.assertEqual(self.a1.publications.get(), self.p1) + @skipUnlessDBFeature('supports_ignore_conflicts') def test_slow_add_ignore_conflicts(self): manager_cls = self.a1.publications.__class__ |