diff options
| author | Loic Bistuer <loic.bistuer@gmail.com> | 2014-03-27 19:32:48 +0800 |
|---|---|---|
| committer | Loic Bistuer <loic.bistuer@gmail.com> | 2014-03-30 15:36:45 +0700 |
| commit | 20399083f49faceef1e48530822137257bca9d6a (patch) | |
| tree | 6f1c65e9284e8f9a1489c99cc0045bfbe7301dc7 /tests/m2m_regress | |
| parent | 2f3e1fe3234f5ebaca7635b0a080c2a751c3c758 (diff) | |
Fixed #19816 -- Pre-evaluate querysets used in direct relation assignments.
Since assignments on M2M or reverse FK descriptors is composed of a `clear()`,
followed by an `add()`, `clear()` could potentially affect the value of the
assigned queryset before the `add()` step; pre-evaluating it solves the problem.
This patch fixes the issue for ForeignRelatedObjectsDescriptor,
ManyRelatedObjectsDescriptor, and ReverseGenericRelatedObjectsDescriptor.
It completes 6cb6e1 which addressed ReverseManyRelatedObjectsDescriptor.
Diffstat (limited to 'tests/m2m_regress')
| -rw-r--r-- | tests/m2m_regress/tests.py | 12 |
1 files changed, 0 insertions, 12 deletions
diff --git a/tests/m2m_regress/tests.py b/tests/m2m_regress/tests.py index d1f85ace3e..105e41b644 100644 --- a/tests/m2m_regress/tests.py +++ b/tests/m2m_regress/tests.py @@ -97,15 +97,3 @@ class M2MRegressionTests(TestCase): # causes a TypeError in add_lazy_relation m1 = RegressionModelSplit(name='1') m1.save() - - def test_m2m_filter(self): - worksheet = Worksheet.objects.create(id=1) - line_hi = Line.objects.create(name="hi") - line_bye = Line.objects.create(name="bye") - - worksheet.lines = [line_hi, line_bye] - hi = worksheet.lines.filter(name="hi") - - worksheet.lines = hi - self.assertEqual(1, worksheet.lines.count()) - self.assertEqual(1, hi.count()) |
