summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2023-03-31 13:48:02 -0400
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-04-04 14:35:21 +0200
commit0e1aae7a5f51408b73c5a29e18bd1803dd030930 (patch)
tree82b504fc96e044c7b8924bcb97bada4a036faf73 /tests
parent79a3ea83b13a336b5dd2963c4dab374b2064f092 (diff)
downloaddjango-0e1aae7a5f51408b73c5a29e18bd1803dd030930.tar.gz
Fixed #34450 -- Fixed multi-valued JOIN reuse when filtering by expressions.
Thanks Roman Odaisky for the report.
Diffstat (limited to 'tests')
-rw-r--r--tests/lookup/tests.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/lookup/tests.py b/tests/lookup/tests.py
index 09b9453449..2dddd826e3 100644
--- a/tests/lookup/tests.py
+++ b/tests/lookup/tests.py
@@ -1357,6 +1357,9 @@ class LookupQueryingTests(TestCase):
cls.s1 = Season.objects.create(year=1942, gt=1942)
cls.s2 = Season.objects.create(year=1842, gt=1942, nulled_text_field="text")
cls.s3 = Season.objects.create(year=2042, gt=1942)
+ Game.objects.create(season=cls.s1, home="NY", away="Boston")
+ Game.objects.create(season=cls.s1, home="NY", away="Tampa")
+ Game.objects.create(season=cls.s3, home="Boston", away="Tampa")
def test_annotate(self):
qs = Season.objects.annotate(equal=Exact(F("year"), 1942))
@@ -1527,3 +1530,19 @@ class LookupQueryingTests(TestCase):
{"year": 2042, "century": "other"},
],
)
+
+ def test_multivalued_join_reuse(self):
+ self.assertEqual(
+ Season.objects.get(Exact(F("games__home"), "NY"), games__away="Boston"),
+ self.s1,
+ )
+ self.assertEqual(
+ Season.objects.get(Exact(F("games__home"), "NY") & Q(games__away="Boston")),
+ self.s1,
+ )
+ self.assertEqual(
+ Season.objects.get(
+ Exact(F("games__home"), "NY") & Exact(F("games__away"), "Boston")
+ ),
+ self.s1,
+ )