summaryrefslogtreecommitdiff
path: root/tests/many_to_many/models.py
diff options
context:
space:
mode:
authorontowhee <82607723+ontowhee@users.noreply.github.com>2023-05-16 19:12:53 -0700
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2024-02-16 08:57:16 +0100
commit66e47ac69a7e71cf32eee312d05668d8f1ba24bb (patch)
tree4e70a219a399f9d8142bfca7d22621ac22960f3d /tests/many_to_many/models.py
parent0d8fbe2ade29f1b7bd9e6ba7a0281f5478603a43 (diff)
Fixed #29725 -- Removed unnecessary join in QuerySet.count() and exists() on a many to many relation.
Co-Authored-By: Shiwei Chen <april.chen.0615@gmail.com>
Diffstat (limited to 'tests/many_to_many/models.py')
-rw-r--r--tests/many_to_many/models.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/many_to_many/models.py b/tests/many_to_many/models.py
index 42fc426990..df7222e08d 100644
--- a/tests/many_to_many/models.py
+++ b/tests/many_to_many/models.py
@@ -78,3 +78,15 @@ class InheritedArticleA(AbstractArticle):
class InheritedArticleB(AbstractArticle):
pass
+
+
+class NullableTargetArticle(models.Model):
+ headline = models.CharField(max_length=100)
+ publications = models.ManyToManyField(
+ Publication, through="NullablePublicationThrough"
+ )
+
+
+class NullablePublicationThrough(models.Model):
+ article = models.ForeignKey(NullableTargetArticle, models.CASCADE)
+ publication = models.ForeignKey(Publication, models.CASCADE, null=True)