diff options
| author | Simon Charette <charette.s@gmail.com> | 2021-05-11 01:19:44 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-05-13 07:53:56 +0200 |
| commit | 386caa5445c42413f300dfc08f0d7c3767b2b2d9 (patch) | |
| tree | 7dfcdaf605ded3ac536c7eb7e7878b20e60a2cf2 /tests | |
| parent | d6b6eda4ed3193745a8d54bf364e5ecf41b7862e (diff) | |
[3.2.x] Fixed #32717 -- Fixed filtering of querysets combined with the | operator.
Address a long standing bug in a Where.add optimization to discard
equal nodes that was surfaced by implementing equality for Lookup
instances in bbf141bcdc31f1324048af9233583a523ac54c94.
Thanks Shaheed Haque for the report.
Backport of b81c7562fc33f50166d5120138d6398dc42b13c3 from main
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/queries/tests.py | 4 | ||||
| -rw-r--r-- | tests/utils_tests/test_tree.py | 5 |
2 files changed, 9 insertions, 0 deletions
diff --git a/tests/queries/tests.py b/tests/queries/tests.py index 9350e3e37e..877d758904 100644 --- a/tests/queries/tests.py +++ b/tests/queries/tests.py @@ -1338,6 +1338,10 @@ class Queries4Tests(TestCase): self.assertEqual(len(combined), 1) self.assertEqual(combined[0].name, 'a1') + def test_combine_or_filter_reuse(self): + combined = Author.objects.filter(name='a1') | Author.objects.filter(name='a3') + self.assertEqual(combined.get(name='a1'), self.a1) + def test_join_reuse_order(self): # Join aliases are reused in order. This shouldn't raise AssertionError # because change_map contains a circular reference (#26522). diff --git a/tests/utils_tests/test_tree.py b/tests/utils_tests/test_tree.py index 154678ff57..279e8813b9 100644 --- a/tests/utils_tests/test_tree.py +++ b/tests/utils_tests/test_tree.py @@ -57,6 +57,11 @@ class NodeTests(unittest.TestCase): self.assertEqual(len(self.node1) + 1, len(node3)) self.assertEqual(str(node3), "(DEFAULT: ('a', 1), ('b', 2), ('c', 3))") + def test_add_eq_child_mixed_connector(self): + node = Node(['a', 'b'], 'OR') + self.assertEqual(node.add('a', 'AND'), 'a') + self.assertEqual(node, Node([Node(['a', 'b'], 'OR'), 'a'], 'AND')) + def test_negate(self): # negated is False by default self.assertFalse(self.node1.negated) |
