diff --git a/docs/releases/1.6.3.txt b/docs/releases/1.6.3.txt index 99b8566270e..a8b63dc72ae 100644 --- a/docs/releases/1.6.3.txt +++ b/docs/releases/1.6.3.txt @@ -14,3 +14,7 @@ several bugs in 1.6.2: * Fixed ``AttributeError`` when using :meth:`~django.db.models.query.QuerySet.bulk_create` with ``ForeignObject`` (`#21566 `_). + +* Fixed crash of ``QuerySet``\s that use ``F() + timedelta()`` when their query + was compiled more once + (`#21643 `_). diff --git a/tests/expressions_regress/tests.py b/tests/expressions_regress/tests.py index 7533e4ee39a..8f87940c9e2 100644 --- a/tests/expressions_regress/tests.py +++ b/tests/expressions_regress/tests.py @@ -281,6 +281,13 @@ class FTimeDeltaTests(TestCase): q2 = str(queryset.query) self.assertEqual(q1, q2) + def test_query_clone(self): + # Ticket #21643 + qs = Experiment.objects.filter(end__lt=F('start') + datetime.timedelta(hours=1)) + qs2 = qs.all() + list(qs) + list(qs2) + def test_delta_add(self): for i in range(len(self.deltas)): delta = self.deltas[i]