1
0
mirror of https://github.com/django/django.git synced 2025-10-26 23:26:08 +00:00

[1.6.x] Fixed #21643 -- repeated execution of qs with F() + timedelta

Thanks Tim Graham for review and Tai Lee for the additional test to prove
this was a regression in 1.6.

Backport of 7f2485b4d1 and 8137215973 from master
This commit is contained in:
Alexey Voronov
2013-12-22 00:03:17 +02:00
committed by Tim Graham
parent f2b513c9e8
commit 5cda1d2702
3 changed files with 19 additions and 0 deletions

View File

@@ -259,6 +259,20 @@ class FTimeDeltaTests(TestCase):
self.days_long.append(e4.completed-e4.assigned)
self.expnames = [e.name for e in Experiment.objects.all()]
def test_multiple_query_compilation(self):
# Ticket #21643
queryset = Experiment.objects.filter(end__lt=F('start') + datetime.timedelta(hours=1))
q1 = str(queryset.query)
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]