Fixed #21643 -- repeated execution of qs with F() + timedelta
Thanks Tim Graham for review.
This commit is contained in:
parent
b80a8357d6
commit
7f2485b4d1
|
@ -111,6 +111,7 @@ class SQLEvaluator(object):
|
||||||
def evaluate_date_modifier_node(self, node, qn, connection):
|
def evaluate_date_modifier_node(self, node, qn, connection):
|
||||||
timedelta = node.children.pop()
|
timedelta = node.children.pop()
|
||||||
sql, params = self.evaluate_node(node, qn, connection)
|
sql, params = self.evaluate_node(node, qn, connection)
|
||||||
|
node.children.append(timedelta)
|
||||||
|
|
||||||
if (timedelta.days == timedelta.seconds == timedelta.microseconds == 0):
|
if (timedelta.days == timedelta.seconds == timedelta.microseconds == 0):
|
||||||
return sql, params
|
return sql, params
|
||||||
|
|
|
@ -274,6 +274,13 @@ class FTimeDeltaTests(TestCase):
|
||||||
self.days_long.append(e4.completed - e4.assigned)
|
self.days_long.append(e4.completed - e4.assigned)
|
||||||
self.expnames = [e.name for e in Experiment.objects.all()]
|
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_delta_add(self):
|
def test_delta_add(self):
|
||||||
for i in range(len(self.deltas)):
|
for i in range(len(self.deltas)):
|
||||||
delta = self.deltas[i]
|
delta = self.deltas[i]
|
||||||
|
|
Loading…
Reference in New Issue